How PDF Compression Really Works (With Visual Examples)

Compressing a PDF is not a single algorithm โ€” it is a sequence of decisions about images, fonts, metadata and stream encoding. This article dissects each stage so you know exactly where your file size comes from.

1. Why PDFs get large

If you ever wondered why a “short” invoice weighs 12 MB, open the file in a hex viewer. You will find three usual suspects: high-resolution raster scans, embedded fonts you never use, and uncompressed streams. Everything else โ€” text, vector shapes, metadata โ€” is tiny.

2. The three big levers

Image downsampling. A scanned page at 600 dpi is beautiful but massive. Downsampling to 150 dpi for screen or 300 dpi for print cuts raster weight by 4โ€“16ร— with no visible loss on most devices.

Font subsetting. A font file like Noto Sans CJK is 20 MB. If your document uses only 200 glyphs, you can embed only those glyphs for < 100 KB.

Stream filter choice. PDF supports FlateDecode (deflate), DCTDecode (JPEG), JPX (JPEG 2000), JBIG2 (bi-tonal) and CCITT (fax). Picking the right filter per object is a huge win.

3. Lossy vs. lossless

Lossless compression never discards bits โ€” it exploits redundancy. Deflate on text streams is pure lossless. Lossy compression trades fidelity for size, which is what JPEG and JPX do with photographs. For colour photos we usually recommend DCTDecode (JPEG, quality 60โ€“75). For bi-tonal scans (black-and-white receipts, line art), JBIG2 is a game-changer, shrinking by 20ร— or more compared to G4 fax.

4. A field experiment

We took a 50-page construction report (147 MB) and ran a six-pass compression:

From 147 MB to 20 MB โ€” a 7ร— reduction with no perceptible visual change on screen.

5. When compression ruins quality

Over-compressing OCR’d scans can cause character substitution bugs โ€” an “8” may turn into “3”. For archival contracts or anything legally binding, keep images at 300 dpi minimum and use lossless JBIG2 (not lossy JBIG2) for bi-tonal pages.

6. Tooling

For scripted workloads, we recommend qpdf --object-streams=generate --compress-streams=y for safe lossless gains and ghostscript -dPDFSETTINGS=/ebook for aggressive but configurable lossy compression. For a hands-off experience use the Compress PDF tool.

7. The future: WebAssembly compressors

Browsers now expose enough WebAssembly performance to run image codecs locally. We are shipping an experimental client-side compressor in 2027 that will shrink files before upload โ€” zero bytes of raw content ever leave your device.

Compression is both science and craft. Lean on tools that let you tune settings, but don’t be afraid to open a hex viewer when you need to understand why a file is big.


Tags: #PDF compression #compress PDF #PDF file size #PDF optimisation


Leave a Reply

Your email address will not be published. Required fields are marked *