I had to email a PDF with several high-resolution images embedded. The original file size was 7.31 MB and this was unnecessary large for a single page PDF. I did not need the very high-resolution of the pictures, but only that the PDF would look good on-screen and in print on a normal inkjet printer.

The magic of Ghostscript
Googling the terms “compressing pdf” revealed several online options for uploading and compressing PDFs, but since I was sitting in front of a Linux computer and didn’t really trust any of these unknown providers I ended up using Ghostscript instead. The following command compressed my PDF from 7.31MB to 674KB in about a second:

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

From the Ghostscript manual it can be seen that there are several qualities to choose from:

  • /screen – selects low-resolution output similar to the Acrobat Distiller “Screen Optimized” setting.
  • /ebook – selects medium-resolution output similar to the Acrobat Distiller “eBook” setting.
  • /printer – selects output similar to the Acrobat Distiller “Print Optimized” setting.
  • /prepress – selects output similar to Acrobat Distiller “Prepress Optimized” setting.
  • /default – selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file.


I tried them all and ended up with the “/printer” quality. Below is a list of the file sizes and my comments:

  • 77KB – output-screen.pdf – I didn’t like this setting, JPEG compression artifacts was very visible and the quality very low.
  • 167KB – output-ebook.pdf – Decent result, but compression clearly visible when zooming a bit.
  • 674KB – output-printer.pdf – Very good result, even when zoomed it looks respectable.
  • 986KB – output-prepress.pdf – Very good indeed, no visible artifacts when zoomed.
  • 373KB – output-default.pdf – Surprisingly not as good as expected with clear artifacts when zoomed.

References
http://milan.kupcevic.net/ghostscript-ps-pdf/
http://www.ghostscript.com/doc/9.05/Ps2pdf.htm