A Lazy Developer's Guide to Reducing PDF Size
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 -
- Use Adobe Acrobat's Compress PDF function,
- Use one of many online tools,
- Export PDF as lower quality JPEG, and then export JPEG as PDF...phew
- 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)