PDF Tools 8 min read • Updated 2026-10-09

How PDF Compression Works: Reducing File Size Without Losing Quality

Learn the science behind PDF compression — from image downsampling and font subsetting to Deflate stream optimization. Understand how to choose the right compression level for web, email, and print.

By Dhaval Joshi, Lead Engineer & Founder of FreeToolkit

What Is Inside a PDF File?

A PDF (Portable Document Format) is not a single flat image — it is a structured container that holds multiple distinct data streams. Understanding this internal architecture is key to knowing how compression works.

Every PDF file contains four primary types of internal data:

  • Text layers: Selectable, searchable character data encoded using embedded font subsets. Text streams are already compact and contribute very little to total file size.
  • Raster images: Photographs, scanned pages, and screenshots stored as bitmap pixel grids. These are almost always the largest component — a single high-resolution photograph can occupy 5–20 MB within a PDF.
  • Vector graphics: Charts, diagrams, logos, and line art stored as mathematical path coordinates. Vectors scale infinitely without quality loss and are extremely space-efficient.
  • Metadata and structure: Cross-reference tables (xref), page trees, bookmarks, form fields, and annotation objects. These contribute a small but non-trivial overhead, especially in documents with hundreds of pages.

When you "compress a PDF," you are selectively reducing the size of one or more of these internal components — primarily the raster images, which account for 70–95% of total file size in most real-world documents.

The Three Core Compression Techniques

Professional PDF compression engines (including the one used by FreeToolkit) apply three complementary techniques:

1. Image Downsampling (Bicubic Interpolation)

Embedded images are resampled to a lower DPI (dots per inch). For example, a 300 DPI photograph scanned for print can be safely downsampled to 150 DPI for email sharing or 72 DPI for web embedding, reducing pixel count by 75% or more.

The bicubic interpolation algorithm calculates each new pixel as a weighted average of 16 surrounding source pixels, producing smooth gradients and preventing the jagged aliasing artifacts that simpler methods (nearest-neighbor, bilinear) introduce.

2. Font Subsetting

A typical PDF may embed full font files containing 2,000+ glyphs (characters) per typeface. If the document only uses 80 unique characters, the remaining 1,920 glyph outlines are dead weight.

Font subsetting strips all unused glyphs from embedded fonts, keeping only the exact characters that appear in the document. This alone can save 200–500 KB per embedded font family.

3. Deflate Stream Recompression

PDF internal data streams (page content, metadata, cross-reference tables) use the Flate/Deflate compression algorithm — the same algorithm behind ZIP files and PNG images. Many PDF creation tools use fast but suboptimal Deflate settings (compression level 1–3 out of 9).

Recompressing these streams at maximum Deflate level (9) can squeeze an additional 5–15% reduction without any data loss whatsoever. This is a purely lossless optimization.

Compression Levels Explained: Low, Medium, and High

Most compression tools — including FreeToolkit's PDF Compressor — offer preset levels that control how aggressively each technique is applied:

LevelImage DPI TargetJPEG QualityTypical Size ReductionBest For
Low200 DPI85%20–40%Archiving, print-ready documents where image clarity is critical
Medium150 DPI70%40–65%Email attachments, document sharing, LMS submissions
High72 DPI50%65–90%Web uploads, government portals with strict size limits (2–5 MB), mobile viewing

Key insight: Documents containing only text and vector diagrams (no photographs) will see minimal difference between compression levels, because there are no raster images to downsample. For such documents, the reduction comes primarily from Deflate recompression and metadata cleanup.

Client-Side vs. Server-Side PDF Compression

Two fundamentally different approaches exist for compressing PDFs in a web application:

Client-side (browser-based): The PDF file never leaves your device. Compression runs entirely inside your browser using WebAssembly (WASM) libraries like pdf-lib. This guarantees 100% privacy — your sensitive contracts, medical records, and financial statements never touch external servers. FreeToolkit uses client-side processing for compression operations where possible.

Server-side: The PDF is uploaded to a secure server, processed by tools like Ghostscript or QPDF, and the result is returned. Server-side engines can apply more aggressive optimizations (advanced image codec selection, structure linearization), but require trust that the server deletes your file promptly. FreeToolkit's server-side processing uses ephemeral isolated workers with automatic file purge immediately after processing.

For maximum privacy with sensitive documents, always prefer client-side compression tools.

Practical Tips for Getting the Smallest PDF

  • Remove unnecessary pages first: Use a PDF splitter to extract only the pages you need before compressing. Fewer pages = smaller file.
  • Convert scanned images to text: If your PDF is a scanned document, running OCR (Optical Character Recognition) first converts pixel images into selectable text, which compresses far more efficiently.
  • Avoid re-compressing already-compressed PDFs: Compressing a PDF that was already compressed at High level will yield minimal additional reduction and may degrade quality. Apply compression once at the appropriate level.
  • Check the output: After compression, open the result and zoom into images and text to verify readability meets your needs. If text looks blurry, switch to a lower compression level.

Written by Dhaval Joshi. Have feedback or questions? Contact us at support@freetoolkit.online.