A Lazy Developer's Guide to Reducing PDF Size

A Lazy Developer's Guide to Reducing PDF Size

Brajesh Sachan
Brajesh Sachan
Table of Contents
Table of Contents

Sometimes you receive PDFs which are too large in size. It could be because the PDF contains images, or it is created by scanning physical pages. There are several ways to reduce the PDF size -

  1. Use Adobe Acrobat's Compress PDF function,
  2. Use one of many online tools,
  3. Export PDF as lower quality JPEG, and then export JPEG as PDF...phew
  4. On Mac OS, use Preview's "Reduce File Size" filter - this doesn't always work - sometimes the output PDF is larger than input.

I sometimes receive PDFs which I need to reduce below 250 KB to upload in my storage. My way of doing this is to use ghostscript.

ghostscript can be downloaded/installed from here for Windows and Linux, while on Mac OS:

brew install ghostscript

To reduce the PDF size, open Terminal/Console, and run:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=<OUTPUT PDF> <INPUT PDF>

The magic happens in PDFSETTINGS, for which the documentation for is available here. To summarize

  • -dPDFSETTINGS=/screen lower quality, smaller size (72 dpi)
  • -dPDFSETTINGS=/ebook better quality, larger size (150 dpi)
  • -dPDFSETTINGS=/prepress same as Acrobat Distiller "Prepress Optimized" setting (300 dpi)
  • -dPDFSETTINGS=/printer same as Acrobat Distiller "Print Optimized" setting (300 dpi)
  • -dPDFSETTINGS=/default useful across a wide variety of uses, which may result in a larger output file

(More Lazy Developer's Guides)



Hey 👋! Discover the best! Now!

Everything to Run Your Business

Get Accounting, CRM & Payroll in one integrated package with Deskera All-in-One.

Great! Next, complete checkout for full access to Deskera Blog
Welcome back! You've successfully signed in
You've successfully subscribed to Deskera Blog
Success! Your account is fully activated, you now have access to all content
Success! Your billing info has been updated
Your billing was not updated