The objects of a document form a tree. The trailer’s Root points at the
catalog; the catalog points at the page tree, the outline, the name dictionary, the
interactive form, the structure tree and the rest; and the page tree leads to every
page, with its resources and contents. “Since” in the tables is the PDF version that
added a key; “2.0 deprecated” means PDF 2.0 says it should no longer be written.
TrailerRoot the catalogreferenceCatalog/Type /Catalog Pages, Outlines, Names, AcroForm, StructTreeRoot, OCProperties, Metadata …onePages/Type /Pages a tree of nodes with Kids and Countone or morePage/Type /Page MediaBox, Resources, Contents, Annotsone a page
The catalog
| 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 /2.0 |
Extensions | dictionary | 1.7 | Developer extensions the file uses |
Pages | dictionary | 1.0 | Required. The root of the page tree |
PageLabels | number tree | 1.3 | Page labels |
Names | dictionary | 1.2 | The name dictionary |
Dests | dictionary | 1.1 | Named destinations, the old form: names to destinations |
ViewerPreferences | dictionary | 1.2 | Viewer preferences |
PageLayout | name | 1.0 | SinglePage (default), OneColumn, TwoColumnLeft, TwoColumnRight, TwoPageLeft and TwoPageRight (1.5) |
PageMode | name | 1.0 | What to show on opening: UseNone (default), UseOutlines, UseThumbs, FullScreen, UseOC (1.5, the layers panel), UseAttachments (1.6) |
Outlines | dictionary | 1.0 | The outline (bookmarks) |
Threads | array | 1.1 | Article threads |
OpenAction | array or dictionary | 1.1 | A destination to show, or an action to run, on opening |
AA | dictionary | 1.4 | Actions for document events: close, save, print |
URI | dictionary | 1.1 | Base, the base URI for relative links |
AcroForm | dictionary | 1.2 | The interactive form |
Metadata | stream | 1.4 | The document’s XMP metadata |
StructTreeRoot | dictionary | 1.3 | The structure tree |
MarkInfo | dictionary | 1.4 | Whether the file is tagged |
Lang | text string | 1.4 | The main language, a BCP 47 tag such as en-GB |
SpiderInfo | dictionary | 1.3 | Web Capture information. 2.0 deprecated |
OutputIntents | array | 1.4 | The colour characteristics of the intended output, as used by PDF/X and PDF/A |
PieceInfo | dictionary | 1.4 | Private data of the programs that made the file |
OCProperties | dictionary | 1.5 | Optional content (layers); required if the file has any |
Perms | dictionary | 1.5 | Permission signatures: DocMDP, and UR3 (usage rights, 2.0 deprecated) |
Legal | dictionary | 1.5 | An attestation of content that could change how a signed page looks, such as JavaScript or external streams |
Requirements | array | 1.7 | Features a reader must have to show the document properly |
Collection | dictionary | 1.7 | Shows the file as a portable collection |
NeedsRendering | boolean | 1.7 | Whether the document must be built from its XFA form. 2.0 deprecated |
DSS | dictionary | 2.0 | The document security store of certificates and revocation data for signatures (earlier as an ETSI extension to 1.7) |
AF | array | 2.0 | Associated files of the whole document (earlier in PDF/A-3) |
DPartRoot | dictionary | 2.0 | The root of the document part hierarchy, as used by PDF/VT |
The page tree
Pages are kept in a balanced tree so that a reader can find page 500 of a long
document without reading 499 page objects. Inner nodes are page tree nodes; leaves
are pages. The order of the pages is the order of a depth-first walk through
Kids.
Page tree nodes
| Key | Type | Since | Meaning |
|---|---|---|---|
Type | name | 1.0 | Required. Pages |
Parent | dictionary | 1.0 | Required except in the root. The node above |
Kids | array | 1.0 | Required. References to the nodes and pages below |
Count | integer | 1.0 | Required. The number of pages, the leaves, under this node |
Resources, MediaBox, CropBox, Rotate | 1.0 | Inherited by the pages below |
A reader should check that Kids does not loop back to a node above,
which damaged and hostile files do.
Page objects
| Key | Type | Since | Meaning |
|---|---|---|---|
Type | name | 1.0 | Required. Page |
Parent | dictionary | 1.0 | Required. The page tree node above |
LastModified | date | 1.3 | When the page was last changed; required with PieceInfo |
Resources | dictionary | 1.0 | Required, here or inherited. The resources the contents use |
MediaBox | rectangle | 1.0 | Required, here or inherited. The page’s full size |
CropBox | rectangle | 1.0 | The part shown and printed; default the MediaBox |
BleedBox | rectangle | 1.3 | The area to clip to in production, with bleed; default the CropBox |
TrimBox | rectangle | 1.3 | The finished page after trimming; default the CropBox |
ArtBox | rectangle | 1.3 | The meaningful content; default the CropBox |
BoxColorInfo | dictionary | 1.4 | How a viewer should draw the boxes |
Contents | stream or array | 1.0 | The content stream, or an array of them read as one; none means an empty page |
Rotate | integer | 1.0 | Degrees clockwise when shown, a multiple of 90; default 0 |
Group | dictionary | 1.4 | The page’s transparency group |
Thumb | stream | 1.0 | A thumbnail image |
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 for a presentation |
Annots | array | 1.0 | The page’s annotations |
AA | dictionary | 1.2 | Actions on opening and closing the page |
Metadata | stream | 1.4 | XMP metadata for the page |
PieceInfo | dictionary | 1.3 | Private data of programs |
StructParents | integer | 1.3 | The page’s key in the structure parent tree; required if it has marked content in the structure |
ID | byte string | 1.3 | A Web Capture identifier. 2.0 deprecated |
PZ | number | 1.3 | The preferred zoom for a captured web page |
SeparationInfo | dictionary | 1.3 | For a colour separation page: which colourant it is |
Tabs | name | 1.5 | Tab order of annotations: R rows, C columns, S structure; 2.0 adds A and W |
TemplateInstantiated | name | 1.5 | The template the page was made from |
PresSteps | dictionary | 1.5 | Steps of a presentation on the page |
UserUnit | number | 1.6 | The size of a user space unit in 1/72 inch, default 1.0, for pages bigger than 200 inches |
VP | array | 1.6 | Viewports: areas with their own measurement scale, as in maps and drawings |
AF | array | 2.0 | Associated files of the page |
OutputIntents | array | 2.0 | Output intents for this page, overriding the document’s |
DPart | dictionary | 2.0 | The document part the page belongs to |
Inheritance
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: Resources, MediaBox,
CropBox and Rotate. To find a page’s value, look in the
page, then its Parent, and so on up to the root. Writers often put one
MediaBox on the root for a document whose pages are all the same size.
No other key is inherited.
Resources
A content stream refers to fonts, images and other objects by short names, such as
/F1 or /Im3. The resource dictionary of the page, form or
pattern maps the names to the objects:
| 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 and scn |
Shading | 1.3 | Shadings, for sh |
XObject | 1.0 | Images and forms, for Do |
Font | 1.0 | Fonts, for Tf |
ProcSet | 1.0 | An array of procedure set names, such as /PDF /Text /ImageB. Ignored by readers; 2.0 deprecated |
Properties | 1.2 | Property lists for marked content, including optional content groups |
Name trees and number trees
A name tree maps strings to objects, sorted by the bytes of the strings; a number tree maps integers. Each node is a dictionary:
| Key | In | Meaning |
|---|---|---|
Kids | root and inner nodes | References to the nodes below |
Names | root and leaves of a name tree | [key1 value1 key2 value2 …], sorted |
Nums | root and leaves of a number tree | The same with integer keys |
Limits | inner nodes and leaves | The smallest and largest key under the node |
A small tree is just a root with Names or Nums. To look a key
up, follow the kid whose Limits contain it.
Where number trees are used
The catalog’s PageLabels and the structure tree’s
ParentTree are number trees.
The name dictionary
The catalog’s Names holds name trees by kind:
| Key | Since | Maps names to |
|---|---|---|
Dests | 1.2 | Destinations |
AP | 1.3 | Annotation appearance streams |
JavaScript | 1.3 | Document-level JavaScript actions, run on opening |
Pages | 1.3 | Visible pages, for forms |
Templates | 1.3 | Hidden template pages |
IDS | 1.3 | Web Capture content identifiers. 2.0 deprecated |
URLS | 1.3 | Web Capture URLs. 2.0 deprecated |
EmbeddedFiles | 1.4 | Embedded files: the attachments panel |
AlternatePresentations | 1.4 | Slide shows. 2.0 deprecated |
Renditions | 1.5 | Media renditions |
Outlines
The outline, shown as bookmarks, is a tree of items held together by doubly linked
lists. The root, the catalog’s Outlines, has Type
Outlines, First, Last and Count.
Each item has:
| Key | Since | Meaning |
|---|---|---|
Title | 1.0 | Required. The text shown |
Parent | 1.0 | Required. The item or root above |
Prev, Next | 1.0 | The items before and after at the same level |
First, Last | 1.0 | The first and last child |
Count | 1.0 | If positive, the item is open and this many descendants are visible; if negative, it is closed and the absolute value is the number of descendants that opening it would show |
Dest | 1.0 | The destination to go to |
A | 1.1 | An action instead of Dest |
SE | 1.3 | The structure element it belongs to |
C | 1.4 | The text colour, three RGB numbers; default black |
F | 1.4 | Style flags: 1 italic, 2 bold |
Destinations
A destination is a page and a view of it, written as an array whose first element is the page object (or, for a link into another file, a page number from 0):
| Form | Since | View |
|---|---|---|
[page /XYZ left top zoom] | 1.0 | That point at the top left, at that zoom; null keeps the current value |
[page /Fit] | 1.0 | The whole page in the window |
[page /FitH top] | 1.0 | The page width, with that coordinate at the top |
[page /FitV left] | 1.0 | The page height, with that coordinate at the left |
[page /FitR left bottom right top] | 1.0 | That rectangle in the window |
[page /FitB] | 1.1 | The page’s bounding box of content in the window |
[page /FitBH top] | 1.1 | The bounding box’s width |
[page /FitBV left] | 1.1 | The bounding box’s height |
A named destination is a name or string that stands for such an array, looked up in
the Dests name tree (or the older catalog Dests dictionary
for names). The value may also be a dictionary with the array in D, and
in PDF 2.0 a structure destination in SD, which points at a structure
element rather than a page.
Page labels
Page labels, from PDF 1.3, are the page numbers a viewer shows, such as i, ii, iii
then 1, 2, 3. The catalog’s PageLabels number tree maps the index of the
first page of each range (from 0) to a label dictionary:
| Key | Meaning |
|---|---|
S | The style: D decimal, R and r upper and lower-case Roman, A and a letters (A to Z, then AA to ZZ); none means no number |
P | A prefix, such as (A-) |
St | The number of the first page of the range, default 1 |
Article threads
A thread, from PDF 1.1, links areas of text in reading order across pages, like a
newspaper story continued on page 7. The catalog’s Threads lists thread
dictionaries; each has F, its first bead, and I,
information such as a title. Beads form a circular list with N (next),
V (previous), T (the thread), P (the page) and
R (the rectangle). PDF 2.0 adds Metadata to a thread.
Viewer preferences
| Key | Since | Meaning |
|---|---|---|
HideToolbar, HideMenubar, HideWindowUI | 1.2 | Hide parts of the viewer; default false |
FitWindow, CenterWindow | 1.2 | Fit the window to the first page; centre it on the screen |
DisplayDocTitle | 1.4 | Show the title from the metadata, not the file name, in the title bar |
NonFullScreenPageMode | 1.2 | The page mode to use after leaving full screen |
Direction | 1.3 | Reading order, L2R (default) or R2L |
ViewArea, ViewClip, PrintArea, PrintClip | 1.4 | Which page box to show and print. 2.0 deprecated |
PrintScaling | 1.6 | None or AppDefault: whether the print dialog scales to fit |
Duplex | 1.7 | Simplex, DuplexFlipShortEdge or DuplexFlipLongEdge |
PickTrayByPDFSize | 1.7 | Choose the paper tray by page size |
PrintPageRange | 1.7 | Pairs of page numbers for the print dialog |
NumCopies | 1.7 | Copies for the print dialog |
Enforce | 2.0 | Preferences the viewer must not let the user override, such as PrintScaling |
Logical structure and tagged PDF
The structure tree, from PDF 1.3, records what the content is: headings, paragraphs,
lists, tables, figures, in reading order. It is what screen readers, reflow and text
export use. Content is tied to it by marked content: a BDC operator with
an MCID number around each piece of page content.
- The catalog’s
StructTreeRoot(Type StructTreeRoot) hasK, the top elements;ParentTree, a number tree from each page’sStructParentsto the elements that own its marked content;IDTree;RoleMap, which maps a writer’s own element types to standard ones; andClassMapfor shared attributes. - Each structure element (
Type StructElem) hasS, its type (Document,H1,P,Table,Figure…),P, its parent,K, its children (other elements, MCIDs, or marked-content and object references),Pg, the page, and optionalAlt,ActualText(1.4),Lang(1.4),E(1.5, the expansion of an abbreviation),TandA, its attributes. - The catalog’s
MarkInfosaysMarked truefor a tagged PDF (1.4).UserProperties(1.6) says the structure carries user properties;Suspects(1.6) is 2.0 deprecated. - PDF 2.0 adds namespaces: the root’s
Namespacesarray and each element’sNS, so that the PDF 1.7 and the PDF 2.0 sets of standard element types can be told apart, along withRefon elements, andPronunciationLexicon,PhoneticAlphabetandPhonemefor speech.
PDF/UA requires a complete structure tree, and PDF/A levels “a” require one too.
Optional content
Optional content, from PDF 1.5, is what programs call layers: parts of pages that can be shown or hidden, such as the languages of a manual or the floors of a plan.
- An optional content group (OCG),
Type OCG, is one layer:Name(required),Intent(VieworDesign) andUsage, a dictionary that says when it should be on, byCreatorInfo,Language,Export,Zoom,Print,View,UserandPageElement. - An optional content membership dictionary,
Type OCMD, combines groups:OCGs, andP, one ofAllOn,AnyOn(default),AnyOffandAllOff; or from 1.6VE, a visibility expression such as[/And ocg1 [/Not ocg2]]. - The catalog’s
OCPropertieshasOCGs, every group in the file;D, the default configuration; andConfigs, others. A configuration hasName,Creator,BaseState(ON,OFForUnchanged),ONandOFFlists,Intent,AS(automatic states by usage),Order(how the layers panel shows the groups),ListMode,RBGroups(groups that act as radio buttons) and from 1.6Locked.
Content is made optional in three ways: in a content stream between
/OC /name BDC and EMC, with the name in the resources’
Properties; by an OC key on a form or image XObject; or by
an OC key on an annotation.
Portable collections
A portable collection, from PDF 1.7, is a PDF that is mainly a container for its
embedded files, which a viewer shows as a list or a set of folders, with the PDF’s own
pages as a cover. The catalog’s Collection has Schema, the
columns to show for each file, with names, types and order; D, the file
to show first; View, D details, T tiles or
H hidden (and C, custom, with Adobe’s extension level 3);
and Sort. Each embedded file’s file specification carries
CI, its values for the columns. Folders, colours and a navigator came in
Adobe’s extension level 3 and are part of PDF 2.0.
Developer extensions
From PDF 1.7 a file can say that it uses extensions to its base version. The
catalog’s Extensions dictionary is keyed by a four-character prefix
registered with ISO, such as ADBE for Adobe or ISO_ for ISO
extensions, and each value is a developer extensions dictionary:
| Key | Since | Meaning |
|---|---|---|
Type | 1.7 | DeveloperExtensions |
BaseVersion | 1.7 | Required. The PDF version the extension builds on, such as /1.7 |
ExtensionLevel | 1.7 | Required. An integer, the level of the extension, such as 3 or 8 for Adobe |
URL | 2.0 | Where the extension is described |
ExtensionRevision | 2.0 | A revision of the level |
A file that uses Adobe’s AES-256 encryption, for example, has
/Extensions <</ADBE <</BaseVersion /1.7 /ExtensionLevel 3>>>>.
PDF 2.0 also lets the value be an array, for several extensions under one prefix.