How to shrink PDFs
Sometimes a PDF document you’ve created is several megabytes in size due to high resolution images. This may cause problems when you want to send this PDF via email if the attachement’s size is limited by your email provider. There is a way you can reduce the file size of an existing PDF without having to render it again with low resolution images.
You can use the pdfwrite device module of Ghostscript to reduce image resolution in existing PDF files.
$ gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dBATCH -sOutputFile=small.pdf large.pdf
The options explained:
-sDEVICE=pdfwrite Output PDF document -dCompatibilityLevel Set Adobe's PDF specification compatibility level >=1.4 for font embedding =1.6 for OpenType font embedding -dPDFSETTINGS =/screen (screen-view-only quality, 72 dpi images) =/ebook (low quality, 150 dpi images) =/printer (high quality, 300 dpi images) =/prepress (high quality, color preserving, 300 dpi images) =/default (almost identical to /screen) -dNOPAUSE Disables the prompt and pause at the end of each page. This may be desirable for applications where another program is driving Ghostscript -dBATCH Exit after last file -sOutputFile Send output to a file, - for stdout, |command for pipe, embed %d or %ld for page #
The compatibility level of the shrunk PDF should be the same as that of the original file to prevent complications. As for the resulting file size you may need to experiment with different PDFSETTINGS options until you get the filesize you desire. For more suffisticated options like paper size, image downsampling and more please refer to the Ghostscript man pages or the online documentation at http://ghostscript.com/doc/current/Use.htm and http://ghostscript.com/doc/current/Ps2pdf.htm.