modern-pdf-lib / PdfOutlineTree
Class: PdfOutlineTree
Defined in: src/outline/pdfOutline.ts:214
The root of the outline tree, containing top-level outline items.
Constructors
Constructor
new PdfOutlineTree():
PdfOutlineTree
Defined in: src/outline/pdfOutline.ts:218
Returns
PdfOutlineTree
Properties
items
items:
PdfOutlineItem[]
Defined in: src/outline/pdfOutline.ts:216
Top-level outline items.
Methods
addItem()
addItem(
title,destination,options?):PdfOutlineItem
Defined in: src/outline/pdfOutline.ts:230
Add a top-level outline item.
Parameters
title
string
Display title.
destination
Navigation target.
options?
Visual style options.
Returns
The newly created item.
removeItem()
removeItem(
item):void
Defined in: src/outline/pdfOutline.ts:246
Remove a top-level outline item.
Parameters
item
The item to remove.
Returns
void
Throws
If the item is not in the tree.
toDict()
toDict(
registry,pageRefs):PdfRef
Defined in: src/outline/pdfOutline.ts:269
Serialize the outline tree to a PDF /Outlines dictionary.
This creates the complete outline object graph:
- A root /Outlines dict with /Type, /First, /Last, /Count
- One dict per outline item with /Title, /Parent, /Prev, /Next, /First, /Last, /Count, /Dest (or /A), /C, /F
All dictionaries are registered in the provided registry and cross-linked via indirect references.
Parameters
registry
Object registry for allocating refs.
pageRefs
readonly PdfRef[]
Array of PdfRef for each page (indexed by page number).
Returns
The indirect reference to the /Outlines root dict.
fromDict()
staticfromDict(dict,resolver,pageRefToIndex):PdfOutlineTree
Defined in: src/outline/pdfOutline.ts:321
Parse an outline tree from an existing /Outlines dictionary.
Parameters
dict
The /Outlines dictionary.
resolver
(ref) => PdfObject | undefined
Function to resolve indirect references to objects.
pageRefToIndex
ReadonlyMap<number, number>
Mapping from page ref object numbers to page indices.
Returns
PdfOutlineTree
A fully populated PdfOutlineTree.