-
Notifications
You must be signed in to change notification settings - Fork 12
/
genpdfs
executable file
·28 lines (24 loc) · 737 Bytes
/
genpdfs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
make_pdf_per_pass() {
# Use GNU parallel to generate dot files, if present.
type parallel &>/dev/null &&
ls -1 *.gv | parallel --no-notice --gnu -- '(dot {} -Tpdf) > {}.pdf' &&
return 0
# Otherwise, generate dot files sequentially.
ls -1 *.gv | while read g; do
dot "${g}" -Tpdf > "${g}.pdf"
done
}
make_pdf_per_pass;
# Concatenate the per-pass PDFs into a single PDF per-compilation.
if type pdftk &> /dev/null; then
for i in func*-pass00-*.gv.pdf; do
base=${i/-*/}
pdftk "${base}"-*.pdf cat output "${base}.pdf"
done
elif type qpdf &> /dev/null; then
for i in func*-pass00-*.gv.pdf; do
base=${i/-*/}
qpdf --empty --pages "${base}"-*.pdf -- "${base}.pdf"
done
fi