Skip to main content
Document Optimization • Technical Architecture

Understanding PDF Compression: Lossless Stream Cleanup vs. JPEG Downsampling Explained

By Pushpendra Sharma • Updated: October 30, 2026 • 9 min read

1. Why Are PDF Files So Unnecessarily Large?

It is common to encounter a 4-page PDF document that consumes 25 megabytes of disk space, making it impossible to email or submit through employment, university, or government portals that enforce strict 100 KB, 200 KB, or 500 KB limits.

PDF bloating typically stems from three structural sources:

  1. Overkill Image Resolution (DPI): Desktop document scanners frequently scan at 300 to 600 DPI (Dots Per Inch) designed for fine-art printing. For screen viewing and web portal verification, 72 to 150 DPI is identical to the human eye while consuming 90% fewer bytes.
  2. Uncompressed Fonts & Glyphs: When saving from Microsoft Word or Adobe InDesign, entire multi-megabyte TrueType or OpenType font libraries are often embedded verbatim inside the document, even if only 20 distinct letters are actually used.
  3. Unpacked Object Streams & Metadata: PDF files often retain incremental revision histories, undo buffers, XML metadata packages (XMP), and uncompressed vector objects across multiple content revisions.

2. The Two Core Compression Strategies

Effective PDF compression is not a single uniform algorithm. Depending on whether your priority is absolute visual precision or hitting a strict byte constraint, two distinct strategies are utilized:

Method A: Lossless Stream Cleanup

Consolidates loose PDF object dictionaries into cross-reference object streams (useObjectStreams: true), applies FlateDecode (zlib deflate) to uncompressed content, strips redundant metadata, and removes unreferenced orphan objects without changing a single pixel.

Method B: Dynamic Image Downsampling

Renders scanned pages or embedded raster photos onto an HTML5 canvas at an optimized target DPI (e.g. 72–110 DPI) and re-encodes the image stream via Discrete Cosine Transform (DCT / JPEG compression) at quality factors between 40% and 85%.

3. Hitting Strict Target Limits: 100 KB & 200 KB Portals

Government portals, passport agencies, and recruitment exams (such as UPSC, SSC, US Visa applications, and state licensing boards) frequently reject files exceeding exactly 100 KB or 200 KB.

Achieving an exact size target requires solving a dynamic ratio equation:

// Dynamic Downsampling Scale Calculation

const targetBytes = targetKB * 1024;

const sizeRatio = targetBytes / originalBytes;

if (sizeRatio < 0.25) {

  scale = 0.70; // ~72 DPI rendering

  jpegQuality = 0.35;

} else if (sizeRatio < 0.50) {

  scale = 0.85; // ~90 DPI rendering

  jpegQuality = 0.50;

}

In the DocuShrink Compress PDF Tool, users can simply toggle the "Set target size" switch and select quick chips (100 KB, 200 KB, 500 KB, 1 MB). The in-browser WebAssembly pipeline calculates the optimal rasterization dimensions and compression coefficients automatically.

4. DPI Breakdown: Which Setting Should You Choose?

Preset / Profile Effective DPI Quality Ratio Best Used For
Max (Smallest file) 72 DPI 40% JPEG Portal uploads, 100 KB limits, email attachments
Balanced (Recommended) 110 DPI 70% JPEG Everyday business documents, invoices, job applications
High Quality 150 DPI 85% JPEG Legal discovery, architectural diagrams, office printing

5. Summary

Effective PDF compression does not require uploading documents to remote cloud servers. By pairing lossless object stream cleanup with precision client-side raster downsampling, DocuShrink allows users to achieve aggressive file size reductions while keeping their confidential data 100% private.

PS

Written by Pushpendra Sharma

Pushpendra is the lead software engineer behind DocuShrink. He specializes in document optimization pipelines, client-side WebAssembly compression algorithms, and offline browser computing.

Related Technical Guides