2 # Original ps2pdf is just a trivial caller to gs too.
3 # That ones is lossless, tries to be closer to PDF/A-1.
4 # It also copies Producer metainformation tag to Creator,
5 # removes all empty metainformation fields, removed fields
6 # with uuid:s, removes Format (that is application/pdf).
15 -dPDFSETTINGS=/default
17 -dCompatibilityLevel=1.4
18 -dPDFACompatibilityPolicy=3 # that will skip some errors about XMP
19 -dAutoRotatePages=/None
21 -sColorConversionStrategy=RGB # advised for PDF/A
22 -sProcessColorModel=DeviceRGB # advised for PDF/A
23 -dAutoFilterColorImages=false
24 -dAutoFilterGrayImages=false
25 -dAutoFilterMonoImages=false
26 -dColorImageFilter=/FlateEncode
27 -dGrayImageFilter=/FlateEncode
28 -dMonoImageFilter=/FlateEncode
34 exiftool $1.pdf | while read l ; do
35 f=${${(s/:/)l}[1]:gs/ //}
36 [[ "$l" =~ ": " ]] || toremove=($f $toremove)
37 [[ "$l" =~ ": uuid:" ]] && toremove=($f $toremove)
39 for i ({1..${#toremove}}) toremove[$i]=-${toremove[$i]}=
40 exiftool -zip -overwrite_original -quiet \
41 -tagsFromFile $1 -Producer\>Creator \
43 [[ -z $LINEARIZE ]] || LINEARIZE=--linearize
44 qpdf $LINEARIZE --compress-streams=y $1.pdf $1.pdf.pdf