How to compress a PDF without losing quality

Where the size comes from, which reductions are free, and where the quality trade-off actually starts.

Updated · 2 min read

Where the size comes from

A PDF of text alone is tiny: a 300-page novel is a few hundred kilobytes. What makes PDFs large is pictures. A scanned page is a full-page image; a report with a dozen photos embeds them at whatever resolution the author's camera produced; a slide deck exported to PDF carries every screenshot at retina size. Fonts add a little, and a poorly written PDF can drag along unused objects, old versions of pages and duplicate resources.

So "compress a PDF" means one of three different things, with very different effects on quality.

Lossless: cleanup and re-compression of streams

The free win. A PDF's internal streams can be deflate-compressed, unused objects dropped, duplicate images and fonts shared, and the file structure rewritten compactly. Nothing visible changes. Gains range from 5 percent on a tidy file to 50 percent or more on one that was edited many times or exported by careless software. Stayput's compress tool does this in "lossless" mode; it is the mode to try first.

Lossy but usually invisible: recompress the images

If the file is still too large, the images inside it are the reason. Recompressing them means decoding each image, optionally reducing its resolution, and re-encoding it as JPG at a chosen quality. At 150 DPI and quality 80 the pages look the same on a screen, and a scanned document drops from 20 MB to 2 MB. The quality loss only becomes visible when printing large or zooming far in. Text, vector drawings and fonts are untouched by this step; only pictures change.

The last resort: flatten to images

Some PDFs resist both steps: heavy vector maps, CAD exports, or files where every page is a complicated overlay of transparent layers. Rendering each page to a single image and rebuilding the PDF from those images makes the size predictable, at the cost of text being no longer selectable or searchable. Use it when nothing else works, and keep the original.

Doing it without uploading

All three steps are routine work for a browser: pdf-lib rewrites the structure, and pdf.js and the canvas API decode and re-encode the images. The compress tool runs all three modes inside your tab, shows the size before and after, and never sends the document anywhere; that matters for exactly the contracts, statements and medical records that tend to need compressing. A 40 MB file compresses in the time an upload would still be showing a progress bar.

Other ways to get under a limit

If only a few pages matter, extract them instead of shrinking the whole file. If the recipient needs a picture of one page rather than the document, convert that page to JPG. And if you are producing the PDF yourself, export at "reduced size" or with images at 150 DPI from the source application, which beats compressing afterwards.

Questions

What is the maximum email attachment size?

Gmail and Outlook.com accept 25 MB per message; corporate mail servers often stop at 10 MB. Aim below 10 MB to be safe.

Does compressing a PDF remove the text layer?

Lossless cleanup and image recompression keep text selectable and searchable. Only the flatten mode turns pages into images.

Why did lossless compression barely change the size?

The file was already compact. Its size is in its images, so the next step is image recompression at a lower DPI.

Is compressing the same as reducing resolution?

Reducing resolution is one part of image recompression. Lossless mode changes no resolution at all.

Tools mentioned in this guide

More guides