Convert a Color PDF to Monochrome¶
Note
Be aware that this procedure will flattern vector images and text in the source PDF into images - the file size will grow in this situation.
pdftk input.pdf burst output "intermediate-%03d.pdf"
for i in intermediate-*.pdf; do
convert -density 150 ${i} -monochrome -quality 100 -sharpen 0x1.0 ${i%.*}_mono.pdf
done
pdftk intermediate-*_mono.pdf output output.pdf
rm intermediate-*.pdf
Not Authorized¶
If ImageMagick / convert
complains about being "not authorized", then edit /etc/ImageMagick-6/policy.xml
:
<policymap>
<!-- snip -->
<policy domain="coder" rights="read|write" pattern="PDF" />
<!-- snip -->
</policymap>
sed -re '/<policy /{/pattern="PDF"/{s/(rights)="[^"]+"/\1="read|write"/}}' \
-i /etc/ImageMagick-6/policy.xml