Skip to main content
BrowserStay

Command Palette

Search for a command to run...

PDF

What is actually inside a PDF

It is not a photograph of a page and it is not a Word document. It is a small file system of drawing instructions — which explains both what you can do with it and what you cannot.

The PDF tools, in one place

A PDF is a container. Inside are numbered objects, a table that says where each one lives, and a tree that says which page uses which of them. Understanding those three things explains most of the strange behaviour people blame on “PDF”.

Objects and the cross-reference table

Every element — a page's contents, a font, an image, a colour space — is an object with a number. At the end of the file (or, in newer files, in a compressed stream at the front) sits the cross-reference table: a list mapping object numbers to byte offsets. A reader jumps to an offset instead of parsing the whole document, which is why a 900-page PDF can open on page 600 in a second.

This is also why “repairing” a PDF is a real job. If the table points at the wrong bytes, the objects are still there but nothing can find them; a repair tool rebuilds the table by scanning the file.

Pages are drawings, not text

A page holds a content stream: a short program of operators. “Move here, set the font, draw these glyphs at these coordinates.” The text you select is a sequence of glyph draws with positions attached, not a paragraph with words in it. There are no sentences, no spaces as characters in the logical sense, and no line breaks — just paint commands.

That single design decision explains three things people find baffling:

  • Copy-paste sometimes comes out with broken words and stray line breaks, because the extractor is guessing where spaces were.
  • Editing text in a PDF is hard. The layout is fixed; changing a word means re-flowing glyphs the original author positioned by hand.
  • Searching works at all only because the file also stores a mapping from glyphs back to characters.

Fonts and images travel with it

A PDF that looks identical on every machine embeds the fonts it uses, usually as subsets — just the glyphs the document needs. Images are stored as compressed streams, typically JPEG for photographs and Flate for screenshots and line art. Vector graphics stay as instructions, which is why a chart zoomed to 800% is still sharp while a scanned page is not.

Why the same file can be two sizes

PDF allows incremental updates: saving appends the changed objects and a new cross-reference section, leaving the old ones in place. It is fast, it is safe for signatures, and it means a file edited ten times carries ten generations of itself. “Save as” rewrites the file from scratch; “Save” often does not. If a document is unexpectedly heavy and every page looks ordinary, this is the first thing to suspect.

What follows from all this

  • Merging, splitting, rotating, stamping are container operations. They copy objects and rewrite the page tree, which is why they are fast and lossless.
  • Compressing means re-encoding the image objects; text and vectors are already small.
  • Editing text is a layout problem, not a parsing problem — hence the price of real PDF editors.
  • Metadata lives in two parallel stores, and cleaning one does not clean the other.

None of it requires a server. Parsing a container, copying objects and rewriting a page tree is ordinary work for a library running in a tab — which is how the tools on this site do it, and why a 300-page merge takes a second rather than an upload.