← All writing

What a PDF is actually made of

Before you compress a document it is worth knowing where its bytes went. Usually it is one image, placed far larger than it is drawn.

Ask why a PDF is 12 MB and the honest answer is almost always the same: one or two images, stored at a resolution far beyond what the page draws them at.

The rest — text, vectors, fonts, the structure holding it together — is usually a rounding error. A forty-page report of pure text is often under 200 KB. Add four photographs from a modern phone and it is 30 MB.

So the first thing TargetSize does with a PDF is tell you where the bytes are: images, fonts, page content, metadata, structure — as a bar that adds up to the file, because parts that do not add up are not an explanation.

An image has no DPI

This is the part that surprises people, and it is the whole basis of compressing a document without wrecking it.

A 3000 × 2000 photograph has no resolution of its own. It is 300 DPI if the page draws it in a 10-inch box, and 1200 DPI if the page draws it in a two-and-a-half-inch one. The only place that number exists is the transform matrix the image is painted under.

Which means the useful question is never “how big is this image?” — it is “how much bigger is it than the space it occupies?” Downsampling by stored pixel count alone shrinks the small logo and leaves the enormous scan untouched. TargetSize walks each page’s drawing operations, tracks the transform, and works out the effective resolution of every placement. An image already at 150 DPI on the page is left alone. One sitting at 900 has an enormous amount to give up before anyone could see the difference.

What each mode is willing to destroy

Compression modes are usually named for how much they compress. Ours are named for what they take away, because that is the thing you actually need to decide.

  • Lossless — structure only. The pages are byte-identical to look at.
  • Balanced — recompresses oversized images. Text, links, bookmarks, forms and accessibility tags all survive, because only image streams are replaced.
  • Scanned document — for page-sized scans: an explicit DPI target, optional grayscale, and cleanup that straightens the page, clears specks and trims margins — each step skipped, and reported as skipped, when it cannot find what it is looking for.
  • Maximum — renders every page to a picture and rebuilds. Text, OCR, forms, links, annotations, layers and signatures are gone. It will not run without an explicit confirmation that lists all of that.

Two things we will not do

A rewrite that came out larger is thrown away. Re-encoding an already optimised JPEG at lower quality routinely produces a bigger file. Every replacement is measured, and one that grew is discarded — so “compressed” can never quietly mean worse.

A signed document is never modified in place. Editing a PDF invalidates its cryptographic signature, permanently. TargetSize detects signatures, says so before anything runs, and saves the result as a separate unsigned copy.

TargetSize is coming to the Chrome Web Store shortly.