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.


Did you find this helpful or fun? Please donate!

donate via btc or eth

btc: 18jCzwsZDGQYcs6Kyv92pd4683cnnxm1Dd
eth: 0xC285F21Cb271Cb4B3F70c4C47B2f7B26063AF590
paypal: 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