Making the File Smaller

What a PDF weighs shows when it is being sent to two thousand people, or still kept decades from now, or opened over a telephone connection at the far end of a field. A document spends a large share of itself on bookkeeping — where each page begins, which font goes where, which area is clickable — and every character of it is written out in plain view.

Packed away, that bookkeeping takes a fraction of the room, and the saving grows with the number of pages because every page adds its own share of it. The document below reports on a second one of twenty-four pages, written both ways, so the two weights sit side by side and neither is a claim. Nothing on any page changes: the same document comes out either way, and only its size differs.

Packing and showing the first page first are asked one at a time. A packed document cannot also be written to show its first page before the rest has arrived, and a request asking for both is refused before a byte is written.

What This Example Shows

  • The same twenty-four pages weighed plainly, then weighed packed.
  • Not one mark on any page different between the two.
  • Packing stays disabled unless you ask for it, and is never enabled quietly.

The Source Code, Complete

Nothing is left out and nothing is simplified: this is the program exactly as it runs, for the developer who uses this library. The third is the description itself: a plain list of what the page has to say, which is what the service is sent.

Read the Rust source Read the Python source Read the JSON source

The Document Itself

Open the document in English Open the document in French Open the document in German Open the document in Spanish Open the document in Italian Open the document in Portuguese

Making the File Smaller, first page

The Same Document in Other Languages

This document weighs 15.2 kB

Examples Near This One

A Minimal PDF

Two identical pages that draw the structure of an invoice with lines and rectangles, without a word of text: the file is about a dozen kilobytes and embeds no font.

Showing Page One Before the File Has Arrived

The same document written twice: once as it is, once with its first page placed at the start of the file. The page gives, for each of the two, the number of bytes a browser must have received before it shows page 1.

Every Paper Size, on Its Own Page

One page for each paper size the library names, from A0 down to A6 and the American sizes, each giving its size in millimetres and inches; then pages laid on their side or upside down, and a banner ten metres long.

Fonts Embedded in the File

Text set in a font embedded in the file, cut down to the letters actually used, and still searchable, copyable and readable aloud.

Every example, by subject