Understanding how PDF compression shrinks your files
What this tool actually does
A PDF's size is usually dominated by the raster photos and scans embedded inside it, not by its text or vector graphics. This tool targets exactly that: it walks through the document with pdf-lib, finds the embedded JPEG images, and re-encodes each one at a lower quality on a canvas, optionally downsampling any that are larger than needed. Text, fonts, and vector line art are left intact, so a compressed page still reads and prints crisply.
Three presets decide how hard it pushes. High Quality re-encodes images at around 82% JPEG quality and caps their long edge near 2200 pixels; Balanced drops to about 62% and 1600 pixels; Minimum Size goes to 45% and 1100 pixels for the smallest result. On save, the file is also repacked using object streams, which trims structural overhead.
When to reach for it
Use it whenever a PDF is too heavy to email, upload to a portal with a size cap, or attach to a web form. Scanned documents and image-rich brochures benefit the most, because their bulk is precisely the raster data being re-compressed. A slide deck exported to PDF with full-resolution screenshots is another classic candidate.
If you must land under a hard limit — say a 200KB upload ceiling — switch to the target-size mode. Instead of a fixed preset, it binary-searches the quality knob and keeps the highest image quality whose output still fits under the number you enter.
A concrete example
Take a 12MB scanned contract. In Balanced mode the tool decodes each embedded JPEG, redraws it onto a canvas at up to 1600px, and re-encodes at 62% quality; the images shrink dramatically while the typed text overlay stays legible, and the result often lands in the 2–4MB range. Turn on Remove Metadata and the author, title, and similar document properties are cleared from the output in the same pass.
Notes and edge cases
Not every PDF can shrink. A text-only file has no images to re-compress, so its size barely moves — that is expected, not a failure. Images stored as PNG or in other non-JPEG encodings are left as they are, and CMYK JPEGs are skipped on purpose because the canvas re-renders them with a color shift. Password-protected PDFs have to be unlocked first, and the 50MB ceiling reflects what can be decoded and re-encoded comfortably on-device. When a file is already well optimized, the compressed copy may come out close to the original size.