If your PDF is large because of photos, you cannot make it much smaller without changing those photos. What you can do is remove detail no reader will ever see. That is the honest version of “without losing quality”: lossless where possible, and lossy only down to the point where your actual use stops benefiting.
So the real question is not “how do I compress this?” but “what will this file be used for?” A PDF read on a laptop and a PDF going to a commercial printer have very different answers.
Lossless and lossy do different jobs
Lossless compression changes how the file is packed. Nothing on the page changes at all, down to the pixel. It can compress uncompressed streams, pack small objects together, remove objects nothing refers to, and drop old revisions. It cannot shrink JPEG photos already in the file, because JPEG data is already compressed.
Lossy compression changes the images themselves, in two separate ways. Downsampling throws pixels away. JPEG recompression stores the remaining pixels less precisely. The two have different failure modes: too few pixels looks soft, and too much JPEG compression looks blocky around edges and text.
We measured both on one test file: 11 pages of text and one page holding a 5919 by 4024 camera photo at 911 pixels per inch, 17,151,934 bytes in total. Ghostscript 10.04 produced the lossy versions, and the image columns come from pdfimages -list.
| Method | File size | Image afterwards | Text selectable |
|---|---|---|---|
| Original | 17,151,934 | 5919 x 4024 (911 PPI) | Yes |
| Lossless re-save | 17,148,125 | Unchanged | Yes |
Ghostscript /prepress | 756,547 | 1950 x 1325 (300 PPI) | Yes |
Ghostscript /printer | 464,132 | 1973 x 1341 (304 PPI) | Yes |
| Custom, 200 DPI | 139,030 | 1300 x 883 (200 PPI) | Yes |
Ghostscript /ebook | 114,739 | 986 x 670 (152 PPI) | Yes |
Ghostscript /screen | 80,209 | 468 x 318 (72 PPI) | Yes |
The lossless pass saved about 4 KB, or 0.02%. Dropping from 911 to 300 PPI saved 96%. On a file like this, resolution is the whole game. The same lossless pass on a text PDF with uncompressed streams took it from 63,722 to 13,665 bytes, a 79% saving, so lossless is far from useless. It depends entirely on what is in the file.
What “quality” really means here
Quality is not a property of a file. It is whether the file still does its job. Three things can go wrong, so check them separately:
- Photo softness. Mostly a matter of pixels per inch at the size it is shown.
- Text legibility in scans. Scanned text suffers first, because small letters have fine edges. A photo at 150 DPI can look fine while a scanned footnote at 150 DPI becomes hard to read.
- Function. Selectable text, links, bookmarks and form fields do not appear in any DPI number, but compression can remove them. This is the trap in many one-click compressors.
Sensible image DPI by use
These are working conventions, not standards. Your printer’s specification overrides them if you have one.
| Use | Colour and greyscale images | Scanned black and white text |
|---|---|---|
| Reading on phones and laptops | 100 to 150 | 200 |
| Emailing to someone who may print it | 150 | 300 |
| Office printing | 200 | 300 |
| Commercial printing | 300 at final size | 600 to 1200 |
Two details are easy to miss. Pixels per inch depends on printed size, so a photo shown large needs more pixels than the same photo as a thumbnail. And a high-resolution display showing a page at 100% can use more than 150 PPI, so if people will zoom into diagrams or maps, stay at 200 or higher for those pages.
Doing it with Ghostscript
Ghostscript’s -dPDFSETTINGS presets are quick, but they tie image quality settings to a fixed DPI. If you want control, set the resolution yourself. This is the command that produced the 200 DPI row above:
gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dQUIET \
-dDownsampleColorImages=true -dColorImageResolution=200 \
-dColorImageDownsampleType=/Bicubic \
-sOutputFile=out.pdf in.pdf
Text stayed text and the embedded Arial subset survived, which we confirmed with pdffonts and pdftotext. Greyscale and monochrome images have their own matching options (-dGrayImageResolution, -dMonoImageResolution). Adobe Acrobat Pro’s PDF Optimizer offers the same controls in a dialog box, and is the better choice if you already pay for it, since it lets you audit the space first.
Using our tool, and when not to
Compress PDF has two kinds of mode, and they behave very differently.
Lossless keeps text selectable and changes nothing visually. Use it first on any PDF made from Word or similar, and always on a file with forms or links you need.
The image modes (High quality at 200 DPI, Balanced at 144 DPI, Smallest file at 96 DPI) work differently from Ghostscript. They draw each whole page and store it as one JPEG. That shrinks scans and photo-heavy files hard, but text stops being text. You lose selection, search, links and form fields, and text pages can get larger than they started. Those modes suit a scan that was only ever a picture of a page.
So for the common case of a text document with big photos, where you want the photos smaller and the text kept real, our tool is the wrong choice. Use the Ghostscript command above or Acrobat’s PDF Optimizer, both of which downsample images and leave text alone.
How to know when to stop
Compression has a floor: past a point, you pay a lot in visible damage for very little in size. In our table, going from 200 DPI to the /screen preset saved another 59 KB and cut the photo from 1300 pixels wide to 468. That is rarely a good trade.
Stop as soon as one of these is true:
- You are under the limit you were trying to hit. If the portal accepts 10 MB, a 9 MB file is finished. Nobody rewards a 2 MB file.
- The next step saves less than about 20%. Beyond that, you are mostly degrading the document.
- You can see damage at normal reading size. Check the smallest text, then a photo with fine detail such as hair or foliage, then any thin lines in charts.
Always compress from the original, and keep it. Compressing an already compressed copy applies JPEG loss on top of JPEG loss, and each round gets you less. If you need a smaller version later, go back to the source.
If you still cannot hit the limit
- Remove pages that do not need to be there. Appendices and scanned attachments are often most of the weight. Split PDF can also divide a file across several uploads if the portal allows it.
- Go to greyscale for scanned forms and letters. Colour adds data and usually no meaning.
- Fix the source. Resizing photos before they go into a Word document beats anything you can do afterwards, because you are compressing once from a clean copy. If you are unsure where the size is going, why PDF files get so large shows how to check.
- Use real scan compression. Acrobat and dedicated scanning software can separate a page into layers using JBIG2 or JPEG 2000 and OCR the text. They get smaller, sharper scans than a whole-page JPEG, at the price of needing that software.
Check the finished file before you send it. Open it, zoom to 100%, search for a word, click a link, and print one page if it will be printed. A compressed PDF that fails any of those has lost quality, whatever its size says.