trailer
└─ /Root → Catalog /Type /Catalog
├─ /Pages → Page tree /Type /Pages /Kids [...] /Count N
│ ├─ Page /Type /Page /Contents /Resources /MediaBox
│ └─ Pages (subtree) intermediate nodes keep large trees balanced
├─ /Outlines bookmarks
├─ /Names name trees: /Dests, /EmbeddedFiles, /JavaScript …
├─ /AcroForm interactive form fields
├─ /Metadata XMP stream (1.4)
├─ /StructTreeRoot logical structure (1.3), Tagged PDF (1.4)
├─ /MarkInfo << /Marked true >> for Tagged PDF (1.4)
├─ /Lang default natural language (1.4)
├─ /Version overrides the header version (1.4)
├─ /OCProperties optional content / layers (1.5)
└─ /Collection portable collection / portfolio (1.7)Read:
Where the tree lives in the file
The tree above is logical, not physical. Nothing in the file is laid out as an indented tree. The objects are just numbered indirect objects (5 0 obj … endobj), written to the body in any order, and the "tree" is the graph you get by following their N 0 R references.
A reader reconstructs it from the bottom of the file upward:
- The trailer gives
/Root→ the catalog's object number, e.g./Root 1 0 R. - The cross-reference table (or xref stream) maps that object number to a byte offset, so the reader seeks straight to
1 0 obj. - From the catalog it follows
/Pages, then each/Kidsentry, resolving everyN 0 Rthrough the xref the same way.
So the root is the trailer's /Root, the links are indirect references, and the xref is the index that turns a reference into a file position. The File anatomy page shows this on a real 6-object file.
Page attributes and inheritance
Four page attributes are inheritable: /Resources, /MediaBox, /CropBox and /Rotate. If a page doesn't have one, walk up /Parent links until a /Pages node does. Forgetting this is the most common bug in hand-written PDF readers.
Page boundaries
| Box | Meaning |
|---|---|
MediaBox | The physical medium. Required (directly or inherited). Default user space is 1/72 inch, so US Letter is [0 0 612 792]. |
CropBox | Visible region when displayed or printed. Defaults to MediaBox. |
BleedBox, TrimBox, ArtBox | Production boxes: bleed area, finished size, meaningful content. Defined in 1.3; display and preview support documented in 1.4. |
1.6 added /UserUnit to scale the 1/72-inch unit for very large pages.
Other structures you'll meet
Sorted key→value maps split into balanced nodes (
/Kids, /Names, /Limits). Used for named destinations, embedded files, page labels and more.A doubly-linked tree of bookmark items (
/First /Last /Next /Prev /Parent), each with a /Title and a destination or action. 1.4 added /C color and /F style flags.[pageRef /XYZ left top zoom], /Fit, /FitH…, either inline or by name via /Dests.Dates look like
(D:20011103142300+01'00'). Text strings are PDFDocEncoding or UTF-16BE starting with the BOM FE FF.