Saturday, August 13, 2011

ghostscript to compress or reduce a pdf file

ghostscript allows you to do amazing things with pdf's etc from the command line. this:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

compresses a large pdf into a manageble size for (eg) email. Replace your file names output.pdf and input.pdf files with your file names.

example: a 17 page scan at 300dpi colour = 135mb - after running it through gs with the settings at 'SCREEN' gives a low quality (just about good enough for screen reading) pdf of 800kb. 'EBOOK' setting gives a nice quality 3.5mb version (recommended).

Other quality settings:

-dPDFSETTINGS=/screen (screen-view-only quality, 72 dpi images)
-dPDFSETTINGS=/ebook (low quality, 150 dpi images)
-dPDFSETTINGS=/printer (high quality, 300 dpi images)
-dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs)
-dPDFSETTINGS=/default (almost identical to /screen)


These tips from: http://www.ubuntugeek.com/ubuntu-tiphowto-reduce-adobe-acrobat-file-size-from-command-line.html and http://milan.kupcevic.net/ghostscript-ps-pdf/ Thanks.

No comments: