Originally published on CatalystCode — includes an interactive Ubuntu CLI command builder where you pick your document type and copy the exact command + verification checks.
If you have ever tried to shrink a sensitive PDF (tax returns, contracts, medical scans, or research papers) on Ubuntu without uploading it to a third-party website, you have probably copy-pasted this Ghostscript incantation from AskUbuntu:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook \ -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
Enter fullscreen mode
Exit fullscreen mode
It works great for 300–600 DPI scans—until you run it on a text/vector report and discover two annoying problems:
Ghostscript can actually make text-heavy PDFs larger or degrade sharp vector diagrams.
If you run qpdf instead , it cleans up object streams losslessly, but won't shrink a 25 MB scanned receipt because it doesn't downsample embedded images.
A Cleaner Offline Workflow: QPDF + Ghostscript + Validation
That…