Skip to content

What a PDF is made of: pages, fonts, images and the table that binds them

By the getPDF team · Published 11 October 2026

The short answer

A PDF is a numbered set of objects (pages, the drawing instructions on each page, fonts, pictures, metadata) plus a cross reference table at the end that says at which byte each object starts, and a short trailer that points at the table. A viewer reads the end of the file first, finds the table, and jumps to what it needs. Most errors make sense with that picture: cut off the end of the file and the table is gone, leave a font object out and another device substitutes one.

What are the parts of a PDF file?

Four parts, in this order in the file. The format is defined in ISO 32000 (ISO 32000-2 is PDF 2.0); here is our invented 3-page invoice, a 2,318-byte file, taken apart:

  1. The header. The first line, %PDF-1.7, says this is a PDF and which version. A file that does not begin with %PDF- is not a PDF, whatever its name says.
  2. The body: numbered objects. Our invoice has 11. Each one starts with its number, as in 6 0 obj, and ends with endobj. Object 2 is the catalog, the document’s root. Object 1 is the page list: “3 pages, they are objects 6, 8 and 10”. Objects 4 and 5 are the fonts, Helvetica and Helvetica-Bold. Object 3 is the metadata (title and producer). Objects 7, 9 and 11 are the pages’ drawing instructions. Objects point at each other with references such as 4 0 R, “see object 4”.
  3. The cross reference table. After the objects comes xref: 12 lines of 10-digit byte offsets, one per object, plus 1 required empty entry. It says object 6 starts at byte 589, object 7 at byte 879, and so on. In our file the table starts at byte 1,999.
  4. The trailer. The last lines name the root object and the metadata object, then startxref 1999 (where the table is) and %%EOF.
A PDF file drawn as a vertical strip: header at the top, then objects (catalog, page list, page, content stream, font, metadata), the cross reference table and the trailer at the bottom. Arrows show the trailer pointing to the table and the catalog, the catalog to the page list, the page to its content stream and font.%PDF-1.7 header1 0 obj page list: 6, 8, 102 0 obj catalog (root)3 0 obj metadata4 0 obj font: Helvetica6 0 obj page 1: size, fonts7 0 obj page 1 drawing (stream)… objects 5, 8 to 11xref 12 byte offsetstrailer Root 2, Info 3startxref 1999 %%EOFread from the endtrailer, then table,then straight to theobject at its offsetreferencescatalog to page list,page list to pages,page to its drawingand its fonts
The invoice file from start to end. A viewer reads the trailer at the end first, follows startxref to the table, and the table to each object.

Newer files often pack many objects into compressed object streams and store the table as a compressed stream too (since PDF 1.5). The idea is the same; you just cannot read it in a text editor.

Follow 1 page through the file

Page 1 of the invoice is object 6. It says: my size is 595.28 by 841.89 points (A4; a point is 1/72 inch), my fonts are objects 4 and 5, my drawing instructions are object 7. Object 7 is a stream, compressed with Flate (the same compression as ZIP). Inflated, it reads like this (shortened):

BT
/Helvetica-Bold-7098480789 20 Tf
1 0 0 1 72 760 Tm
<496E766F69636520323032362D30343132> Tj
ET

In words: begin text (BT), use the bold font at 20 points (Tf), move to 72 points from the left and 760 from the bottom (Tm), show these letters (Tj), end text (ET). The letters are written as hexadecimal codes; decoded, they say “Invoice 2026-0412”. The next blocks place “Invoice total: 1,190.00 EUR” at 14 points and the payment terms at 11 points, each at its own coordinates.

A picture works the same way: the page names an image object, and the drawing instructions place and scale it. A scanned page is 1 instruction that draws 1 big picture across the whole page, which is why it has no text to search.

Why is text in a PDF not stored as text?

Because the format describes how a page looks, not what it says. There are no paragraphs, no lines, often no spaces: just runs of letters placed at coordinates in a font, in whatever order the program that wrote the file chose. Some programs write a page letter by letter, some write the footer first.

That has 3 effects you meet every day:

  • Copying is interpretation. A viewer rebuilds sentences from positions, and columns or tables can come out interleaved. The scrambled copy-paste guide shows why and what to do.
  • Editing is hard. Changing a word means rewriting a run of positioned letters in a font that may only carry the letters the original used. getPDF’s editor does exactly that, and swaps in a bundled font, and says so, when the file’s own font cannot draw the new letters.
  • Meaning is optional. Headings, reading order and alt text exist only if the file carries tags, a separate structure (a structure tree hung off the catalog); Inspect says whether a file has one, and the tagged PDF guide explains them.

What does this model explain about broken files?

  • A cut-short file will not open. The table and the trailer sit at the very end, so a download that stops early loses exactly the part a viewer reads first. We cut the invoice at 99 % of its length, removing the last 24 bytes (the end of the trailer, the startxref line and %%EOF): getPDF’s engine said it “could not be read as a PDF”. The same happened to a 5.7 MB photo file cut at 99 %, 90 % and 50 %.
  • “Damaged” files often recover anyway. Every object announces itself with n 0 obj, so some viewers rebuild a broken table by scanning the whole file for those markers. A file that opens in 1 viewer and not another is often this case. The broken PDF guide walks through it.
  • Files grow when saved. The format allows an appended save: changed objects, a new table and a new trailer are added at the end, and the old versions stay in the file. Many programs save this way; a file edited 10 times can carry 10 versions of a page. getPDF’s editor writes the file in full, so a changed line leaves no earlier copy, except on a digitally signed file, where it appends to keep the signature valid, and says so.
  • Fonts can be missing. A font is an object that may or may not include the font program itself. If it does not, each device substitutes one, and the page looks different there.
  • A password protects the content, not the structure. In an encrypted file the streams and strings are encrypted, but the objects, the table and the trailer are still visible. That is why a viewer can tell you a file needs a password before it can show anything.

What does this tour skip?

Annotations (notes, highlights and form fields, which sit on top of the page as their own objects), encryption in detail, tags, signatures and attachments each deserve their own page. The PDF privacy guide covers passwords and permissions, and the hidden content guide covers what a file can carry out of sight.

How do you look inside your own PDF?

You do not need a hex editor. Drop the file on Inspect: it reads the objects on your device and lists what they add up to, the pages and their sizes, each font and whether it is embedded, the pictures and their share of the file, the security settings, signatures, scripts, attachments, whether the file is tagged and which language it declares, and both metadata stores. If it says the file “could not be read as a PDF”, you now know the likely reason: the end of the file, with its table, is missing or broken.

Try it here, nothing is uploaded

PDF · any size

The honest part

This is the model, simplified for reading the errors you meet; the full format is ISO 32000. Inspect shows the parts that explain size, fonts and safety; it does not show raw objects or the table itself. For that, open a small uncompressed file in a text editor, as we did with the invoice above, or use a developer tool such as qpdf.

Questions

What is inside a PDF file?

A header, a set of numbered objects (the pages, their drawing instructions, fonts, pictures, metadata), a cross reference table that says at which byte each object starts, and a trailer that points at the table and at the document's root object.

What is the xref table in a PDF?

The cross reference table: a list of byte offsets, one per object, so a viewer can jump straight to any page or font without reading the whole file. It sits at the end of the file, which is why a cut-short download often will not open at all.

Why can't I copy text from a PDF in the right order?

Because a PDF stores text as runs of letters placed at coordinates, not as sentences and paragraphs. Copying means the viewer guesses the order from positions. Columns and tables are where the guess goes wrong.

Can I look inside a PDF without a hex editor?

Yes. Inspect lists the parts that matter: pages and sizes, fonts and whether they are embedded, pictures and their share of the file, security, metadata and attachments. It runs on your device; nothing is uploaded.

The tools for this job