Use the odfpy api for `Openbaar Schrijver' book.
[openbaar_schrijver.git] / unoconv / transform_gray.sh
blob6e3d3d16f75f93efebd5de7ce7ce6738d11f5596
1 #!/bin/bash
3 # This script runs from inside a folder that has one or more .odts in it.
4 # You need the following packages installed:
5 # - unoconv
6 # - ps2pdf
7 # - psutils
8 # - ghostscript
9 # - pdftk
11 echo "Step 1: convert all odts in this folder to pdf"
13 unoconv -f pdf *.odt;
15 # -sPAPERSIZE=a4 -dFIXEDMEDIA
17 echo "Step 2: convert all pdfs in this folder to ps"
19 for i in *.pdf;
20 do pdftops $i;
21 rm $i;
22 done
24 echo "Step 3: scale all ps in this folder from A4 to A5"
26 for i in *.ps;
27 do psresize -PA4 -pA5 $i "scaled_"$i;
28 done
30 echo "Step 4: convert all scaled ps back to pdf"
32 for i in "scaled_"*.ps;
33 do ps2pdf -sPAPERSIZE=a5 $i;
34 done
36 echo "Step 5: remove all ps"
38 for i in *.ps;
39 do rm $i;
40 done
42 echo "Step 6: put all scaled pdfs together in brief.pdf, gedicht.pdf and verhaal.pdf"
44 mkdir -p love;
45 pdftk *.pdf cat output love/love.pdf;
46 pdftk scaled_brief_*.pdf cat output love/brief.pdf;
47 pdftk scaled_verhaal_*.pdf cat output love/verhaal.pdf;
48 pdftk scaled_gedicht_*.pdf cat output love/gedicht.pdf;
50 echo "Step 6b: convert brief.pdf, gedicht.pdf and verhaal.pdf to grayscale + PDF1.3"
52 cd love;
53 for i in *.pdf;
54 do gs -sOutputFile="gray_"$i -sDEVICE=pdfwrite -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray -dCompatibilityLevel=1.3 -dNOPAUSE -dBATCH $i < /dev/null;
55 done
56 cd ../;
58 echo "Step 7: remove all scaled pdfs"
60 for i in "scaled_"*.pdf;
61 do rm $i;
62 done