Skip to content

modern-pdf-lib


modern-pdf-lib / PdfOutlineItem

Class: PdfOutlineItem

Defined in: src/outline/pdfOutline.ts:85

A single node in the outline tree. Each item has a title, a destination, and zero or more child items.

Constructors

Constructor

new PdfOutlineItem(title, destination, options?): PdfOutlineItem

Defined in: src/outline/pdfOutline.ts:114

Create a new outline item.

Parameters

title

string

Display title for the bookmark.

destination

OutlineDestination

Navigation target.

options?

OutlineItemOptions

Visual style options.

Returns

PdfOutlineItem

Properties

bold?

optional bold: boolean

Defined in: src/outline/pdfOutline.ts:102

Whether the title is displayed in bold.


children

children: PdfOutlineItem[]

Defined in: src/outline/pdfOutline.ts:93

Child outline items.


color?

optional color: object

Defined in: src/outline/pdfOutline.ts:99

Optional colour for the outline text (RGB, 0-1 range).

b

b: number

g

g: number

r

r: number


destination

destination: OutlineDestination

Defined in: src/outline/pdfOutline.ts:90

Where clicking this bookmark navigates.


isOpen

isOpen: boolean

Defined in: src/outline/pdfOutline.ts:96

Whether children are initially expanded.


italic?

optional italic: boolean

Defined in: src/outline/pdfOutline.ts:105

Whether the title is displayed in italic.


title

title: string

Defined in: src/outline/pdfOutline.ts:87

The displayed bookmark title.

Methods

addChild()

addChild(title, destination, options?): PdfOutlineItem

Defined in: src/outline/pdfOutline.ts:142

Add a child outline item.

Parameters

title

string

Display title.

destination

OutlineDestination

Navigation target.

options?

OutlineItemOptions

Visual style options.

Returns

PdfOutlineItem

The newly created child item.


getVisibleDescendantCount()

getVisibleDescendantCount(): number

Defined in: src/outline/pdfOutline.ts:177

Count all visible descendants (for the /Count entry).

Per the PDF spec:

  • If the item is open, /Count is the total number of visible descendants (children + their visible descendants).
  • If the item is closed, /Count is the negative of the total number of descendants that would be visible if opened.

Returns

number

The count value for the /Count entry.


removeChild()

removeChild(item): void

Defined in: src/outline/pdfOutline.ts:158

Remove a child outline item.

Parameters

item

PdfOutlineItem

The child item to remove.

Returns

void

Throws

If the item is not a direct child.

Released under the MIT License.