The logical structure of a PDF, from version 1.3, records what its content is rather than where it goes on the page: headings, paragraphs, lists, tables and figures, in reading order. Tagged PDF, from version 1.4, adds rules that make a file’s structure fit for reflow and for screen readers. The content streams stay as they are; marked-content operators tie stretches of content to elements of a separate tree of dictionaries. A file before PDF 1.3 has none of this.
The structure tree root
The catalog’s StructTreeRoot is a dictionary:
| Key | Since | Meaning |
|---|---|---|
Type | 1.3 | StructTreeRoot |
K | 1.3 | The top structure elements, one or an array |
IDTree | 1.3 | A name tree from element IDs to elements |
ParentTree | 1.3 | A number tree from each page’s StructParents and each object’s StructParent to the elements that own its content |
ParentTreeNextKey | 1.3 | The next integer free to use as a key in ParentTree |
RoleMap | 1.3 | Maps a writer’s own structure types to standard ones, such as /Heading1 /H1 |
ClassMap | 1.3 | Maps class names to attribute objects shared by many elements |
Structure elements
| Key | Since | Meaning |
|---|---|---|
Type | 1.3 | StructElem |
S | 1.3 | Required. The structure type: a standard type or a name mapped by RoleMap |
P | 1.3 | Required. The parent element or root |
ID | 1.3 | A byte string that identifies the element, for IDTree |
Pg | 1.3 | The page that holds the content items directly below this element, unless they say otherwise |
K | 1.3 | The children: content items or other elements, one or an array |
A | 1.3 | Attribute objects, one or an array; each entry may be followed by a revision number |
C | 1.3 | Attribute class names, one or an array, also with revision numbers |
R | 1.3 | The element’s revision number, default 0 |
T | 1.3 | A title, as text |
Lang | 1.4 | The language of the element |
Alt | 1.3 | Alternate text for those who cannot see it, such as a figure’s description |
ActualText | 1.4 | The exact text of the content, replacing it |
Content items
An element’s K entries may be other elements or content items of three
kinds:
- A marked-content identifier: an integer, the MCID of a
marked-content sequence on the page
Pg. In the content stream the sequence is written/P <</MCID 3>> BDC … EMC. - A marked-content reference, a dictionary of
Type MCR:Pg, the page if not the element’s;MCID;Stm, the content stream the sequence is in, if it is a form XObject or annotation appearance;StmOwn, the object that owns that stream. - An object reference, a dictionary of
Type OBJR:Pg, the page, andObj, an object such as an image XObject, a form XObject or an annotation, which itself has aStructParentkey.
An image or annotation that is used in the structure has a StructParent
key, and a page or form with marked content has StructParents. A reader
looks that integer up in ParentTree to go from content back to its
element. For a page the value is an array indexed by MCID; for a single object it is
the element itself.
Attributes
An attribute object is a dictionary, or a stream with a dictionary, whose
O key names its owner, the application or standard that defines its other
keys. Standard owners:
O | Meaning |
|---|---|
Layout | Layout attributes |
List | List attributes |
PrintField | Attributes of a form field shown as text |
Table | Table cell attributes |
XML-1.00, HTML-3.20, HTML-4.01, OEB-1.00, RTF-1.05, CSS-1.00, CSS-2.00 | Attributes that follow those specifications, for conversion back to them |
A class named in C looks its attribute objects up in ClassMap.
An attribute given directly in A overrides one of the same name from a
class. C and A entries may each be followed by a revision
number: an attribute is current only if its number equals the element’s
R.
MarkInfo
The catalog’s MarkInfo, PDF 1.4, has Marked, true for a
tagged PDF.
Standard structure types
Tagged PDF defines a set of standard types. A reader understands any file written with
them. Where a writer uses its own names, RoleMap maps them to standard
ones, possibly in several steps.
| Kind | Types |
|---|---|
| Grouping | Document Part Art Sect Div BlockQuote Caption TOC TOCI Index NonStruct Private |
| Paragraph and heading | P H H1 H2 H3 H4 H5 H6 |
| List | L LI Lbl LBody |
| Table | Table TR TH TD THead TBody TFoot |
| Inline text | Span Quote Note Reference BibEntry Code Link Annot |
| Ruby and warichu | Ruby RB RT RP Warichu WT WP |
| Illustration | Figure Formula Form |
Standard attributes
Layout (O = Layout)
| Attribute | Applies to | Values |
|---|---|---|
Placement | any | Block, Inline, Before, Start, End |
WritingMode | any | LrTb (default), RlTb, TbRl |
BackgroundColor, BorderColor, Color | any | RGB colours as three numbers, or for BorderColor an array of four |
BorderStyle | any | None, Hidden, Dotted, Dashed, Solid, Double, Groove, Ridge, Inset, Outset, one or four |
BorderThickness, Padding | any | A number or four numbers |
SpaceBefore, SpaceAfter, StartIndent, EndIndent, TextIndent | block | Numbers |
TextAlign | block | Start, Center, End, Justify |
BBox | illustrations and tables | The bounding box on the page |
Width, Height | illustrations, table cells | Auto or a number |
BlockAlign | table cells | Before, Middle, After, Justify |
InlineAlign | table cells | Start, Center, End |
TBorderStyle, TPadding | tables | As BorderStyle and Padding, for table cell borders |
BaselineShift, LineHeight | inline | A number; LineHeight may be Normal or Auto |
TextDecorationColor, TextDecorationThickness | inline | An RGB colour; a number |
TextDecorationType | inline | None, Underline, Overline, LineThrough |
RubyAlign | Ruby | Start, Center, End, Justify, Distribute |
RubyPosition | Ruby | Before, After, Warichu, Inline |
GlyphOrientationVertical | inline | Auto, −180, −90, 0, 90, 180, 270, 360 |
ColumnCount, ColumnGap, ColumnWidths | grouping | Numbers or arrays |
List (O = List)
ListNumbering: None (default), Disc,
Circle, Square, Decimal,
UpperRoman, LowerRoman, UpperAlpha,
LowerAlpha.
PrintField (O = PrintField)
Role: rb radio button, cb check box,
pb push button, tv text value. checked:
on, off, neutral. Desc: the
text.
Table (O = Table)
RowSpan, ColSpan, integers defaulting to 1;
Headers, element IDs of a cell’s header cells; Scope:
Row, Column, Both.
Artifacts
Content not part of the document’s text, such as page numbers or decorative
rules, is marked /Artifact in the content stream, so that it is left out
of the reading order. Its property list may say what kind, with Type:
Pagination, Layout or Page; BBox,
its bounding box; and Attached, the edges of the page it is tied to:
Top, Bottom, Left, Right.
Marks in the content stream
Property lists for BDC can carry MCID, tying a sequence to
structure; Lang, Alt and ActualText, describing
the sequence when the structure tree does not. Span is the usual tag for
a stretch given only such properties.