# Private PDF compressor

Experiment by Seemant Shekhar (Shipped). https://www.seemant.design/lab/pdf-compressor

Our decks and documents carry sensitive numbers, and the usual fix for a file too big to email is an online compressor. I built an internal one instead: upload a PDF, pick a level, download a smaller copy. Nothing leaves our infrastructure.

- **Built for**: Internal use at Heaps
- **Status**: Shipped, running on our own server
- **Stack**: Python, FastAPI, pikepdf, fontTools, Pillow

- Video: A 10-second run on a sample file: pick a level, compress, download.

## Why

Sales decks, proposals and reports can hold client and revenue details. Uploading them to an outside “compress PDF” site is a quiet data risk, so the one hard rule was: no third-party service, no outbound calls, files deleted as soon as the download is sent.

## Quality first, not size first

Four levels, from High quality to Smallest size, each described by what you will see, not by a number. Design tools often embed an image far larger than it appears on the page, so the compressor works out how big each image is actually shown and keeps only the resolution that size needs.

Testing a real deck against Adobe Acrobat’s compressor showed small text in dashboard screenshots going unreadable on aggressive settings. So images that look like screenshots get a protected minimum resolution, while photos still compress hard.

## The rebuild

Partway through, our IT team ruled out AGPL-licensed libraries, which removed the engine the first version ran on. I rebuilt the image and font handling on license-clean libraries and checked every step by rendering pages before and after: pixel-identical across more than a hundred pages of real documents.

## What I took from it

The design work was in the trade-offs: level names people understand, refusing to let a “smaller” level ever produce a bigger file, and choosing readable text over a few extra percent of size.
