comparison2026-06-25·7 min

PDF Compression: Methods Compared

Ghostscript vs qpdf vs pdf-lib: which PDF compression engine to choose? Technical analysis and benchmark.

PDF compression engines

PDF compression consists of reducing file size by optimizing images, fonts, and internal structures. Three engines dominate: Ghostscript, qpdf, and pdf-lib.

Ghostscript is the industry standard for PDF compression. It rerasterizes images at lower resolution and applies optimal JPEG compression.

qpdf specializes in structure transformation (linearization, stream optimization) but does not rerasterize images.

pdf-lib (pure JavaScript) allows basic manipulations but offers no real image compression.

Benchmark: reduction rate by engine

On a 24 MB reference PDF (report with high-resolution images):

Ghostscript "screen" level (72 dpi): 92% reduction → 1.9 MB. Quality sufficient for screen reading.

Ghostscript "ebook" level (150 dpi): 78% reduction → 5.3 MB. Good quality/size compromise.

Ghostscript "printer" level (300 dpi): 45% reduction → 13.2 MB. Print quality preserved.

qpdf (linearization only): 3% reduction → 23.3 MB. No image compression.

pdf-lib (no image compression): 1% reduction → 23.8 MB. Insignificant.

Conclusion: Ghostscript is by far the best PDF compression engine. SafePDF uses it for its three compression levels.

The 3 SafePDF compression levels

Low level (screen, 72 dpi): ideal for emailing or screen reading. Typical reduction of 80-95%.

Medium level (ebook, 150 dpi): good compromise for comfortable reading and basic printing. Typical reduction of 60-80%.

High level (printer, 300 dpi): preserves print quality. Typical reduction of 30-50%.

The level choice depends on usage: email → low, archiving → medium, professional printing → high.

PDF compression limitations

Compression cannot indefinitely reduce a PDF. An already compressed PDF (images already in JPEG) will have a lower reduction rate.

Vector PDFs (graphics, diagrams) compress less well than image-based PDFs.

Compression with rerasterization (Ghostscript) can degrade text quality. The "high" level (300 dpi) preserves text sharpness.

SafePDF processes all your PDFs 100% locally. No file ever leaves your machine.