13 June 2021

How to programmatically combine & compress PDFs

combine & compress PDFs

Here’s a quick way to combine and compress PDF files via the command-line.

Combine files:

pdfunite *.pdf slides.pdf

Compress file:

gs -sDEVICE=pdfwrite -dCompatabilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dBATCH -dColorImageResolution=150 -sOutputFile="slides-compressed.pdf" "slides.pdf"

Installation:

Easy peasy—but you might need to install some dependencies to make this work. The pdfunite utility is part of the hefty poppler package and gs is Ghostscript. On a mac with Homebrew you can install them via:

brew install poppler gs

Take a stretch break or make a cup of tea while poppler installs dependencies like imagemagick, ffmpeg, awscli, python, sqlite, and more. Or maybe with all these clamps and popplers, go watch an episode of Futurama.




Interested in working with me at Superset to help shape the future of virtual fitness and to empower people to launch their own businesses online? We’re hiring a mobile engineer. 💪🤓📱 Apply online



Did you find this helpful or fun? paypal.me/mrcoles
comments powered by Disqus

Peter Coles

Peter Coles

is a software engineer living in NYC who is building Superset 💪 and also created GoFullPage 📸
more »

github · soundcloud · @lethys · rss