Compress a PDF Without Losing Quality: What Actually Shrinks It
I compressed a scanned PDF and a text-only PDF four different ways and measured every result. The scan went from 9.2 MB to 1.6 MB with text I couldn't tell apart from the original. The text PDF got bigger. Here is why, and how to do the version that works, on your own machine.
The short answer: almost all of a large PDF's weight is images, usually scans. Resize those images to about 150 pixels per inch and re-save them as JPEG, and the file shrinks a lot while text stays readable. If your PDF has no images, there is very little to gain, and some tools make it worse. Do it locally (Preview on a Mac, pypdf or Ghostscript anywhere) rather than uploading a contract or a payslip to a website.
The two test files
On November 27, 2026, on macOS 26.7.3, I made two PDFs that look like what people actually try to email:
- scan.pdf: three letter size pages of a report, rendered at 300 pixels per inch with a little scanner grain and a slight tilt on two pages, saved as JPEG at quality 95. 9,208,192 bytes.
- report.pdf: a four page text-only report printed to PDF from headless Chrome 158. 25,493 bytes.
Then I compressed each one with every method I could run here: Preview's Reduce File Size filter, a lossless pass with pypdf 7.2.0, and an image pass with pypdf and Pillow 13.
Results: the scan
file bytes images inside
scan.pdf (original) 9,208,192 2550 x 3300
lossless pass 9,208,020 2550 x 3300
Preview, Reduce Size 2,758,948 1224 x 1584
pypdf, 200 ppi, q85 2,795,861 1700 x 2200
pypdf, 150 ppi, q80 1,627,176 1275 x 1650
Three things stand out.
The lossless pass saved 172 bytes. Compressing page streams and removing duplicate objects is safe, but a scan is one big image per page, and an image already stored as JPEG can't be squeezed losslessly. Tools that promise "no quality loss" and still shrink a scan are re-encoding the images. That is fine, as long as you know it.
Resolution is the lever. Going from 300 to 150 ppi keeps a quarter of the pixels. With JPEG quality 80 on top, the file came out 82% smaller.
Preview landed between my two settings. Its filter file (/System/Library/Filters/Reduce File Size.qfilter) sets JPEG quality 0.7 and scales images to 144 ppi, which matches the 1224 x 1584 images it produced.
Then the part that matters: I rendered the same patch of body text from each file at 200% zoom and compared them side by side. I couldn't see a difference between the original and any of the three compressed versions. That is for normal body text. Fine print, signatures and photos deserve their own look before you send.
Results: the text-only PDF
file bytes
report.pdf (original) 25,493
lossless pass 25,763
Preview, Reduce Size 43,078
Both made it bigger. Chrome had already compressed the page content and embedded only the font glyphs it used, so there was nothing left to remove. Preview rewrote the file in its own way and added 69%. It also left a small structural problem: pypdf printed Ignoring wrong pointing object 21 0 (offset 0) when reading Preview's output. So the rule is simple. If a PDF is mostly text and already small, leave it alone. A compressor can't improve text, which is drawn from font outlines rather than pixels.
Compress in Preview on a Mac
- Open the PDF in Preview.
- Choose File, then Export.
- In the Quartz Filter menu, choose Reduce File Size.
- Save under a new name, so the original stays as it was.
- Compare sizes in Finder, and open the new file at 100% to check the page that matters most.
Nothing leaves your machine. The downside is that you can't choose the resolution or quality, and on a text PDF it can backfire, as shown above.
Compress with Python: you choose the resolution
This is the script behind the 150 ppi result. It resizes every image and re-saves it as JPEG. Install with pip install pypdf pillow.
from pypdf import PdfWriter
from PIL import Image
def shrink(src, dst, ppi=150, source_ppi=300, quality=80):
w = PdfWriter(clone_from=src)
for page in w.pages:
for img in page.images:
im = img.image
s = ppi / source_ppi
im = im.resize((round(im.width * s), round(im.height * s)), Image.LANCZOS)
img.replace(im, quality=quality)
w.compress_identical_objects(remove_duplicates=True, remove_unreferenced=True)
w.write(dst)
shrink("scan.pdf", "scan-150-q80.pdf")
Two cautions from writing it. The script assumes the scan's resolution (300 here). Check yours first, because shrinking an image that is already 150 ppi by half makes it blurry. And on pypdf 7, the old argument names remove_identicals and remove_orphans raise a DeprecationError. Use the names above. The pypdf file size guide lists the other options.
I also tried converting the pages to grayscale, since the scan was black text on white. It saved only 2.4% more (1,587,512 bytes), so it isn't worth losing colour for.
Compress with Ghostscript on Linux and Windows
Ghostscript is the usual command line choice on servers. I couldn't install it on this Mac (Homebrew fails to build it here), so I have no measured output for it. This is the command and the settings it is documented to take:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 \
-dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH \
-sOutputFile=output.pdf input.pdf
The -dPDFSETTINGS presets (/screen, /ebook, /printer, /prepress) set image resolution, compression and font handling in one go. The exact values for each preset are in the Ghostscript documentation for the pdfwrite device. Read them rather than trusting a number from a blog, mine included. Ghostscript re-creates the whole PDF, so check forms, links and bookmarks in the output.
What compression breaks
- Digital signatures. A signature covers the exact bytes of the signed file. Any tool that rewrites the file, compression included, means a viewer can no longer confirm that the document is the one that was signed. Compress first, sign after, or don't compress signed documents at all.
- Small print and fine lines suffer first when you lower resolution. If the page has them, try 200 ppi before 150.
- Searchable text in scans. If someone ran OCR on the scan, the text layer normally sits under the image. Check that the output is still searchable with Command F.
Keeping it private
Every method on this page runs on your own machine. That matters because the PDFs people compress to make them small enough for email are often the sensitive ones. SecureBin doesn't have a PDF compressor. If you build the PDF yourself from photos or screenshots, shrink the images before they go in. The Image Compressor runs in your browser and nothing is uploaded. If you send the result to someone who needs to confirm it arrived intact, give them its SHA-256 from the Hash Generator, which also hashes files locally.
Related reading: PDF optimization for web, email and print, merging PDFs without uploading them, converting HTML to PDF.