Building the PDF Compressor: When 10MB Becomes 800KB
Compression is part science, part art. Getting the balance right between file size and quality kept me up more nights than I expected.
The PDF compressor was the first tool where I felt genuinely proud of the output — not just the code, but what it produced.
The challenge with compression is that everyone wants different things. A lawyer wants their documents readable and sharp at 100% zoom. A student wants a file small enough to email without their university's 5MB attachment limit kicking in. A photographer wants quality above all else.
I built three compression levels — Low, Medium, High — but the real engineering was in figuring out what to optimize at each level. Images inside PDFs are often the biggest culprits. Most PDFs from scanners embed images at 300 DPI when 150 DPI is perfectly readable on screen. That alone cuts file size in half.
Then there's font embedding. Many PDFs embed entire font files when they only use 40 characters. Subsetting the fonts — only keeping what's actually used — shaves off another chunk.
My proudest moment: compressing a 47MB scanned document down to 3.8MB with no visible quality loss. I showed my friend and he genuinely didn't believe it was the same document. That felt good.