All Tools / Blog / How to Compress a PDF Without Losing Quality

How to Compress a PDF Without Losing Quality

4 min read

A 20 MB PDF that should be 2 MB is a common problem. Email attachments bounce, upload limits reject files, and nobody wants to wait 10 seconds for a document to open. The good news: most oversized PDFs have a lot of headroom for compression without any visible quality loss.

Here's how to think about it and what actually works.

Why PDFs are larger than they need to be

Before compressing blindly, it helps to understand why the file is large:

  • Unoptimized images — a PDF exported from Word or Illustrator may embed full-resolution PNG or TIFF images when a compressed JPEG at 150 DPI would look identical on screen.
  • Embedded fonts — fonts can add 1–5 MB per font face. Subsetting (keeping only the glyphs actually used) cuts this down.
  • Duplicate objects — copy-pasted elements or page backgrounds can repeat the same resource multiple times.
  • Uncompressed streams — older or poorly-exported PDFs skip compression on object streams entirely.
  • Hidden layers or metadata — Illustrator and InDesign often embed full editing data in exported PDFs.

Knowing the cause tells you what technique will help most.

Technique 1: Re-export from the source

If you have the original document (Word, Google Docs, Figma, InDesign), re-exporting is almost always the best option. Choose "Optimize for web/screen" or "Smallest file size" — these presets downsample images to 96–150 DPI and subset fonts automatically.

In Adobe Acrobat: File → Save As Other → Reduced Size PDF.

In LibreOffice: Export as PDF → choose "JPEG compression" for images.

In Word: File → Export → Create PDF/XPS → Options → Bitmap compression.

Technique 2: Ghostscript (command line)

Ghostscript is free, available on all platforms, and produces the best compression ratios. It re-renders the PDF at a target DPI, recompresses images, and strips most metadata.

gs -sDEVICE=pdfwrite \
   -dCompatibilityLevel=1.4 \
   -dPDFSETTINGS=/ebook \
   -dNOPAUSE -dBATCH -dQUIET \
   -sOutputFile=output.pdf \
   input.pdf

The -dPDFSETTINGS presets control quality:

Setting Target DPI Best for
/screen 72 DPI Email, web preview
/ebook 150 DPI Reading on screen
/printer 300 DPI Home printing
/prepress 300 DPI + color Professional print
/default No change Lossless stream compression only

For most use cases, /ebook is the sweet spot — noticeably smaller than the original but still sharp enough to read comfortably.

Technique 3: img2pdf + pngquant for image-heavy PDFs

If your PDF is essentially a stack of scanned images, compress the images first, then reassemble:

# Extract pages as images (requires poppler)
pdftoppm -r 150 input.pdf page

# Compress images
pngquant --quality=65-80 *.png

# Reassemble
img2pdf page-*.png -o output.pdf

This workflow is especially effective for scanned documents where the original scanner saved 600 DPI TIFFs.

Technique 4: Online tools

When you don't have command-line tools available, browser-based compressors handle the heavy lifting. Upload the PDF, choose a quality level, download the result — no software installation needed, and the file never has to leave your browser if the tool processes client-side.

The key thing to check: does the tool process files in your browser (client-side) or send them to a server? For sensitive documents like contracts or medical records, client-side processing is safer.

What "lossless" compression actually means for PDFs

Lossless compression removes duplicate data, optimizes streams, and strips unnecessary metadata without changing any pixel values. The result looks identical to the original. You can get 20–40% size reduction this way on many PDFs — worth doing even if you need to preserve full print quality.

Lossy compression goes further by downsampling images (reducing resolution) and applying JPEG compression. For a 300 DPI press-ready PDF, dropping to 150 DPI screen-quality cuts image data to about 25% of the original — huge savings at the cost of print quality.

For anything that will only ever be read on screen, lossy at 150 DPI is fine.

How much compression is realistic?

Original content Typical reduction
Scanned document (600 DPI TIFF) 85–95% smaller
InDesign/Illustrator export 60–80% smaller
Word/Google Docs export 30–60% smaller
Already-optimized PDF 5–15% smaller
Text-only PDF 5–10% smaller

If a tool claims to compress a text-only PDF by 80%, be skeptical — there isn't that much to compress.

When not to compress

Avoid compression when:

  • The PDF is destined for a professional print shop (they need 300+ DPI).
  • The file contains digitally signed content — compression can invalidate signatures.
  • You're archiving legal or medical documents (use PDF/A format instead).

Key takeaways

  • Re-export from the source first; it's lossless and often the most effective.
  • Ghostscript's /ebook preset is the best all-purpose command-line option.
  • Choose 150 DPI for screen-only documents; 300 DPI if printing.
  • Lossless-only compression (stream optimization) gives 20–40% reduction with zero quality change.
  • For sensitive documents, use a client-side tool so files stay on your device.