The objects of a PDF form a tree, with references across it. The trailer’s
Root points at the document catalog. The catalog points at the page tree,
whose leaves are the pages, and at the document-wide parts: the outline, named
destinations, the form, the structure tree and the metadata. Each page points at its
content streams and the resources they use. This page lists the dictionaries of that
tree as PDF 1.0 to 1.4 define them.
trailerRoot → the catalogoneCatalogPages → the root of the page tree; Outlines, Names, AcroForm …onePagesKids → more page tree nodes or pages, and inherited attributesone or morePageContents, Resources, MediaBox, Annotsone a page
The document catalog
A dictionary with /Type /Catalog, named by the trailer’s
Root. Its keys in these versions:
| Key | Type | Since | Meaning |
|---|---|---|---|
Type | name | 1.0 | Required: Catalog |
Version | name | 1.4 | The PDF version, if later than the header’s, such as /1.4 |
Pages | dictionary | 1.0 | Required, indirect: the root of the page tree |
PageLabels | number tree | 1.3 | The page labels |
Names | dictionary | 1.2 | The name dictionary |
Dests | dictionary | 1.1 | Named destinations, names to destinations (the 1.1 form; see Destinations) |
ViewerPreferences | dictionary | 1.2 | How a viewer should show the document; see Viewer preferences |
PageLayout | name | 1.0 | SinglePage (the default), OneColumn, TwoColumnLeft or TwoColumnRight |
PageMode | name | 1.0 | What to show beside the page on opening: UseNone (the default), UseOutlines, UseThumbs or FullScreen |
Outlines | dictionary | 1.0 | Indirect: the root of the outline (bookmarks) |
Threads | array | 1.1 | Indirect: the article threads |
OpenAction | array or dictionary | 1.1 | A destination to show, or an action to run, when the document opens |
AA | dictionary | 1.4 | Additional actions for document events: close, save, print |
URI | dictionary | 1.1 | A Base URI for relative URI actions |
AcroForm | dictionary | 1.2 | The interactive form |
Metadata | stream | 1.4 | Indirect: the document’s XMP metadata |
StructTreeRoot | dictionary | 1.3 | The structure tree |
MarkInfo | dictionary | 1.4 | Whether the document is tagged: Marked true |
Lang | text string | 1.4 | The natural language of the text, such as (en-GB) |
SpiderInfo | dictionary | 1.3 | Web Capture: how pages were captured from the web |
OutputIntents | array | 1.4 | The colour characteristics of the intended output devices, as for PDF/X |
PieceInfo | dictionary | 1.4 | Private data of the programs that made the document |
The page tree
Pages are not kept in a list but in a balanced tree, so that a reader with a very
long document can find page 5,000 without reading every page before it. The inner
nodes have /Type /Pages; the leaves are page objects. A document with
a handful of pages usually has one Pages node with all pages as its
kids.
Page tree nodes
| Key | Type | Meaning |
|---|---|---|
Type | name | Required: Pages |
Parent | dictionary | Required except in the root: the node above, indirect |
Kids | array | Required: references to the nodes and pages below, in page order |
Count | integer | Required: the number of pages (leaves) below this node |
Resources, MediaBox, CropBox, Rotate | various | Attributes the pages below inherit |
To find page n, start at the root and go down: in each node, skip kids
whose Count (or 1, for a page) does not reach n, subtracting
as you go. The page order is the order of a depth-first walk. A reader should
check for loops and for a Count that does not match.
Page objects
A dictionary with /Type /Page, a leaf of the page tree. Its keys in
these versions:
| Key | Type | Since | Meaning |
|---|---|---|---|
Type | name | 1.0 | Required: Page |
Parent | dictionary | 1.0 | Required, indirect: the page tree node above |
LastModified | date | 1.3 | When the page was last changed; required with PieceInfo |
Resources | dictionary | 1.0 | Required, inheritable: the resources the page’s content uses |
MediaBox | rectangle | 1.0 | Required, inheritable: the page’s full size, in default user units of 1/72 inch |
CropBox | rectangle | 1.0 | Inheritable: the area shown or printed; defaults to the MediaBox |
BleedBox | rectangle | 1.3 | The area to clip to in production, with bleed; defaults to the CropBox |
TrimBox | rectangle | 1.3 | The finished page after trimming; defaults to the CropBox |
ArtBox | rectangle | 1.3 | The meaningful content; defaults to the CropBox |
BoxColorInfo | dictionary | 1.4 | How to draw the boundaries on screen |
Contents | stream or array | 1.0 | The content stream, or an array of streams read as if joined, with white space between; none means an empty page |
Rotate | integer | 1.0 | Inheritable: degrees to turn the page clockwise when shown, a multiple of 90; default 0 |
Group | dictionary | 1.4 | A transparency group for the page |
Thumb | stream | 1.0 | A thumbnail image of the page |
B | array | 1.1 | The article beads on the page |
Dur | number | 1.1 | Seconds to show the page in a presentation |
Trans | dictionary | 1.1 | The transition effect when the page is shown in a presentation |
Annots | array | 1.0 | The page’s annotations |
AA | dictionary | 1.2 | Actions when the page is opened or closed |
Metadata | stream | 1.4 | XMP metadata for the page |
PieceInfo | dictionary | 1.3 | Private data of the programs that made the page |
StructParents | integer | 1.3 | The page’s key in the structure tree’s parent tree |
ID | byte string | 1.3 | Web Capture: the digital identifier of the page’s parent |
PZ | number | 1.3 | Web Capture: the preferred zoom factor |
SeparationInfo | dictionary | 1.3 | For a page that is one colour separation of another |
A minimal page:
2 0 obj
<< /Type /Page /Parent 3 0 R /Resources 6 0 R /Contents 4 0 R /MediaBox [0 0 15 14] >>
endobj
3 0 obj
<< /Type /Pages /MediaBox [0 0 15 14] /Count 1 /Kids [ 2 0 R ] >>
endobj
Inherited attributes
Four page keys can be set on a page tree node instead, and then apply to every page below it that does not set its own:
ResourcesMediaBoxCropBoxRotate
To find a page’s value, look in the page, then its parent, and so on up to the
root. The value is taken whole: a page’s own Resources replaces its
parent’s, it is not merged with it. MediaBox and
Resources are required, so they must be found somewhere on the way up.
Resource dictionaries
A content stream names the fonts, images and other objects it uses by short names,
such as /F1 or /Im3. The resource dictionary maps those
names to objects, one subdictionary a kind:
| Key | Since | Maps names to |
|---|---|---|
ExtGState | 1.2 | Graphics state parameter dictionaries, for gs |
ColorSpace | 1.0 | Colour spaces, for CS and cs |
Pattern | 1.2 | Patterns, for scn in a Pattern colour space |
Shading | 1.3 | Shadings, for sh |
XObject | 1.0 | Images and form XObjects, for Do |
Font | 1.0 | Fonts, for Tf |
ProcSet | 1.0 | An array of procedure set names: PDF, Text, ImageB, ImageC, ImageI |
Properties | 1.2 | Property lists, for marked content |
ProcSet told PostScript printers which sets of procedures to load for
a page. From PDF 1.4 Adobe called the feature obsolete, and readers ignore it. The dictionary in
the small PDF 1.3 example is
<< /ProcSet [ /PDF ] /ColorSpace << /Cs1 7 0 R >> /ExtGState << /Gs1 8 0 R >> >>.
Name trees
A name tree maps strings to objects, sorted, in a tree that can hold any number of entries and be searched without reading all of it. The keys are strings, not names, despite the name. Each node is a dictionary:
| Key | In | Meaning |
|---|---|---|
Kids | root and inner nodes | References to the nodes below |
Names | root (if it is the only node) and leaves | A flat array of pairs: key string, value, key string, value …, sorted by key, bytes compared in order |
Limits | inner nodes and leaves | The smallest and largest keys below or in this node |
To look up a key, start at the root and follow the kid whose Limits
contain it, then search the leaf’s Names.
Number trees
The same as a name tree, but keyed by integers. Leaves have a Nums
array of pairs, integer and value, sorted; Limits holds the smallest
and largest integers. Page labels and the structure parent tree are number trees.
The name dictionary
From PDF 1.2 the catalog’s Names entry holds name trees for objects
that are found by name rather than by reference:
| Key | Since | The tree maps names to |
|---|---|---|
Dests | 1.2 | Named destinations |
AP | 1.3 | Annotation appearance streams |
JavaScript | 1.3 | Document-level JavaScript actions, run when the document opens |
Pages | 1.3 | Visible pages, by name, for templates |
Templates | 1.3 | Invisible template pages that forms can copy |
IDS | 1.3 | Web Capture content sets, by digital identifier |
URLS | 1.3 | Web Capture content sets, by URL |
EmbeddedFiles | 1.4 | File specifications of embedded files |
AlternatePresentations | 1.4 | Alternate presentations, such as slide shows |
The outline
The outline is the bookmarks panel: a tree of titled items, each going to a place
in the document. The catalog’s Outlines points at the outline
dictionary:
| Key | Meaning |
|---|---|
Type | Outlines, optional |
First, Last | The first and last top-level items |
Count | The number of items shown when open; left out if there are none |
Each item is a dictionary in a doubly linked list of siblings:
| Key | Type | Since | Meaning |
|---|---|---|---|
Title | text string | 1.0 | Required: the text shown |
Parent | dictionary | 1.0 | Required: the parent item, or the outline dictionary |
Prev, Next | dictionary | 1.0 | The previous and next siblings |
First, Last | dictionary | 1.0 | The first and last children |
Count | integer | 1.0 | Positive when open: the number of descendants shown; negative when closed: minus the number of visible descendants it would show |
Dest | name, string or array | 1.0 | The destination |
A | dictionary | 1.1 | An action instead of Dest |
SE | dictionary | 1.3 | The structure element the item refers to |
C | array | 1.4 | The colour of the text, three numbers in DeviceRGB; default black |
F | integer | 1.4 | Style flags: bit 1 italic, bit 2 bold |
A reader walks the list with First and Next, going down
through First of each item, and should stop at loops, which damaged
files have.
Destinations
A destination is a page and a view of it. Explicitly, it is an array whose first element is the page (a reference to a page object, or a page number in links to other files) and whose second is the kind of view:
| Array | Since | View |
|---|---|---|
[page /XYZ left top zoom] | 1.0 | Put (left, top) at the top left corner of the window, at this zoom; null or 0 for any of them keeps the current value |
[page /Fit] | 1.0 | The whole page in the window |
[page /FitH top] | 1.0 | The page’s width in the window, with top at the top |
[page /FitV left] | 1.0 | The page’s height in the window, with left at the left |
[page /FitR left bottom right top] | 1.0 | This rectangle in the window |
[page /FitB] | 1.1 | The bounding box of the page’s contents in the window |
[page /FitBH top] | 1.1 | The width of the bounding box, with top at the top |
[page /FitBV left] | 1.1 | The height of the bounding box, with left at the left |
A destination can also be named, so that a link survives a change of page. In PDF
1.1 the name is a name object, looked up in the catalog’s Dests
dictionary. From PDF 1.2 it can be a string, looked up in the Dests
name tree of the name dictionary. The value is the
array, or a dictionary whose D entry is the array.
Page labels
From PDF 1.3 pages can have labels, such as i, ii, iii for the front matter and 1,
2, 3 for the rest. The catalog’s PageLabels is a
number tree keyed by page index, counting from 0. Each
entry starts a range of pages that runs to the next entry:
| Key | Meaning |
|---|---|
Type | PageLabel, optional |
S | The numbering style: D decimal, R upper-case Roman, r lower-case Roman, A upper-case letters (A to Z, then AA to ZZ), a lower-case letters; none means labels are the prefix only |
P | A prefix, such as (A-) |
St | The number of the first page in the range; default 1 |
<< /Nums [0 << /S /r >> 4 << /S /D >>] >>
labels pages i to iv, then 1, 2, 3 from the fifth page.
Article threads
From PDF 1.1 a thread joins parts of a page and later pages into one article that a
reader can follow, as in a newspaper. The catalog’s Threads array lists
thread dictionaries; each has F, its first bead, and I, a
dictionary of information like the document’s. A bead is a dictionary:
| Key | Meaning |
|---|---|
Type | Bead, optional |
T | The thread; required in the first bead |
N, V | The next and previous beads; the list is circular |
P | The page the bead is on |
R | The bead’s rectangle on that page |
Each page lists its own beads in B.
Viewer preferences
From PDF 1.2 the catalog’s ViewerPreferences asks a viewer to show the
document a certain way:
| Key | Since | Default | Meaning |
|---|---|---|---|
HideToolbar | 1.2 | false | Hide the toolbars |
HideMenubar | 1.2 | false | Hide the menu bar |
HideWindowUI | 1.2 | false | Hide scroll bars and navigation, showing only the page |
FitWindow | 1.2 | false | Size the window to the first page |
CenterWindow | 1.2 | false | Put the window in the centre of the screen |
DisplayDocTitle | 1.4 | false | Show the document’s title, not the file name, in the title bar |
NonFullScreenPageMode | 1.2 | UseNone | The page mode on leaving full-screen mode |
Direction | 1.3 | L2R | Reading order, L2R or R2L, for side-by-side pages |
ViewArea, ViewClip, PrintArea, PrintClip | 1.4 | CropBox | Which page boundary to show and print |
Logical structure
From PDF 1.3 a document can carry its structure, separate from its layout: the
headings, paragraphs, lists, tables and figures, in reading order. The catalog’s
StructTreeRoot starts a tree of structure elements:
| Key | In | Meaning |
|---|---|---|
K | root and elements | The children: elements, or marked-content identifiers on a page, or references to annotations and XObjects |
ParentTree | root | A number tree from each page’s StructParents to the elements its content belongs to |
RoleMap | root | Maps a writer’s own element types to standard ones |
ClassMap | root | Named sets of attributes |
IDTree | root | A name tree from element IDs to elements |
S | elements | The element type, such as /P, /H1, /Table |
P | elements | The parent |
Pg | elements | The page its content is on |
Alt, ActualText, Lang | elements | Alternative text, replacement text and language (ActualText and Lang from 1.4) |
The content belongs to an element through marked
content: /P << /MCID 3 >> BDC … EMC in the content
stream, and 3 as a kid of the element. PDF 1.4 added Tagged PDF, a set
of standard element types and rules that let text be reflowed and read aloud, and
the catalog’s MarkInfo with /Marked true to say a document
follows them.