PDF Compression: What the Bytes Actually Are (and Where They Go)

ToolHQ TeamJuly 30, 20267 min read

A single slide deck emailed as a PDF can arrive at 47 megabytes. The same deck, run through a decent compression pass, often lands under 4. Nothing in the document changed -- the fonts are the same, the images look identical, the text is all there. The bytes went somewhere. Understanding where they went tells you something useful about how to make PDF files smaller more intelligently than any slider labeled low / medium / high can.

PDFs are not files in the way a photograph or a Word document is a file. They are containers. Inside a PDF, the text your readers see, the images they look at, the fonts that render it all correctly, the structural metadata that tells a PDF reader where page 7 starts -- these are all separate objects, each potentially compressed with a different algorithm, each stored as its own stream of bytes inside the container. When a PDF is bloated, the bloat is almost never uniform. It is coming from one specific type of object, usually images, and knowing that changes what compression actually means.

Why PDFs Are Larger Than They Need to Be

The most common source of PDF bloat is embedded images that were never properly compressed before the PDF was created. When you export a presentation to PDF from most desktop applications, the software embeds images at near-original quality by default. A single photograph shot on a modern phone camera contains between 8 and 25 megabytes of data uncompressed. An exported slide deck with twelve such photographs, even if each was resized to fit a slide, can carry enormous amounts of pixel data if the application did not apply aggressive compression during export.

The second most common source is font embedding. Modern PDFs embed font files to ensure correct rendering on systems that do not have the font installed. A single variable-weight web font can occupy several hundred kilobytes inside a PDF. A document using five or six custom fonts may carry several megabytes of font data. Font subsetting -- the practice of embedding only the specific characters used in the document rather than the entire typeface -- reduces this substantially, but not all PDF creators do it.

The third source, less common but significant in scanned documents, is uncompressed or poorly compressed raster scans. A scanned page at 300 DPI in color is a large bitmap. Without compression, it stores every pixel value for every channel of every dot.

The Algorithms Inside a PDF

Unlike JPEG or PNG, which apply a single compression scheme to the entire file, PDF applies compression at the stream level. This means a single PDF document can use four or five different algorithms simultaneously, each matched to the content type it compresses.

Text and vector content -- the actual characters, curves, and drawing operators that describe what appears on a page -- are typically compressed with Flate encoding, which is the same Deflate algorithm used inside ZIP files and gzip. Deflate combines two techniques: LZ77, which identifies repeated sequences of bytes and replaces them with compact references to their earlier occurrence, and Huffman coding, which assigns shorter binary codes to the byte patterns that appear most often. Text compresses extremely well this way. A page of English prose, represented as PDF drawing operators and Unicode characters, compresses to roughly half its size under Flate, because language is highly repetitive at the byte level.

Color photographs embedded in PDFs use JPEG compression internally. When an application like Adobe Acrobat Distiller creates a PDF, it decompresses any images it finds and then recompresses them according to its own compression settings for that content type. The JPEG inside the PDF is a distinct, separately compressed object from the PDF's overall structure.

Black and white scanned documents use JBIG2, a specialized algorithm for bitonal images published as an ISO standard in 2000. JBIG2 can achieve three to five times better compression than alternative methods on black-and-white scanned pages because it recognizes recurring shapes and stores them as templates rather than per-pixel data. The letter e appearing four hundred times in a scanned document gets stored once, with references pointing back to that stored pattern every subsequent time.

PDF 1.5, released in 2003, introduced another structural efficiency: object streams and cross-reference streams. These group the PDF's internal bookkeeping records together and compress them as a single unit, rather than leaving them uncompressed at the end of the file as earlier versions did. Many older PDFs still carry uncompressed cross-reference tables simply because they were created before this feature existed.

What a Compressor Actually Does

When you run a PDF through a compression tool, several things happen in sequence. The tool opens the container, enumerates all the streams inside, and evaluates each one.

For image streams, the tool checks the current compression and quality settings. If an image is stored at JPEG quality 90 when quality 70 would be visually indistinguishable at the image's display dimensions, the tool decompresses and recompresses it at the lower setting. It may also downsample images: a photograph stored at 300 dots per inch inside a document designed for screen reading needs at most 150 DPI to look sharp on any monitor. Downsampling reduces the total pixel count before recompression, which reduces file size regardless of the compression algorithm applied.

For font streams, the tool checks whether the full font is embedded when only a subset is needed. If a 450-kilobyte font file was embedded but the document only uses 23 of its characters, subsetting replaces the full font with a 30-kilobyte subset.

For structural streams, the tool may convert pre-1.5 cross-reference tables to compressed object streams, and apply or tighten Flate compression on streams that were left uncompressed.

Finally, many compressors strip optional metadata streams -- document history, editing application information, comment layers, embedded thumbnails -- that contribute to file size without affecting the document's readable content.

Where Quality Is Actually Lost

The only irreversible step in PDF compression is recompressing images at lower JPEG quality. Everything else -- structural compression, font subsetting, metadata removal, DPI downsampling for screen-optimized documents -- preserves the readable content completely.

JPEG recompression compounds in the same way it does for standalone images. If a PDF already contains an image that was JPEG-compressed during scanning, extracting and recompressing it at a lower quality setting applies quantization twice. The second pass degrades the image from the artifacts of the first pass, not from the original. For archival documents, this matters. For a slide deck being emailed, it almost certainly does not.

The practical rule is this: compression is safe when the document's purpose is screen reading or email transmission, and the images in it were originally captured at higher resolution than needed. It is worth being more conservative when the PDF will be printed at high quality, when it contains text scanned as an image rather than OCR'd to searchable text, or when it is a legal or archival document where absolute pixel-fidelity of embedded images is required.

Conclusion

Most PDFs people compress are presentations, reports, and form letters. For these, aggressive compression delivers a file one-fifth to one-tenth the original size with no visible change under normal reading conditions. That 47-megabyte slide deck lands at 4 megabytes not because anything was hidden or deleted, but because the container was storing its content with far more redundancy than any reader ever needed.

ToolHQ's PDF Compressor handles this process in your browser -- the file never reaches a server -- applying the stream-level analysis and recompression that turns an oversize PDF into something you can actually email.

Frequently Asked Questions

Does compressing a PDF damage the text quality?

No. Text in PDFs is compressed with Flate (Deflate), a lossless algorithm. Recompressing text streams never degrades readability. Only image recompression at lower JPEG quality causes any visible change.

Why do scanned PDFs compress so much better than exported ones?

Scanned PDFs typically contain large uncompressed or loosely compressed bitmap images. Applying JBIG2 for black-and-white scans or JPEG recompression for color scans can achieve 3 to 10 times reduction.

Is it safe to compress a legal or archival PDF?

Be cautious. If the PDF contains scanned images of original documents, JPEG recompression during compression is irreversible. Keep a backup of the original before compressing anything with archival value.

What is font subsetting in a PDF?

Embedding only the characters actually used in the document rather than the full typeface file. A document using 40 of a font's 800 glyphs can shrink its embedded font from 400 KB to roughly 25 KB.

Try These Free Tools