Class: Bookmark

PDFNet. Bookmark


new Bookmark()

A %PDF document may optionally display a document outline on the screen, allowing the user to navigate interactively from one part of the document to another. The outline consists of a tree-structured hierarchy of Bookmarks (sometimes called outline items), which serve as a 'visual table of contents' to display the document's structure to the user.

Each Bookmark has a title that appears on screen, and an Action that specifies what happens when a user clicks on the Bookmark. The typical action for a user-created Bookmark is to move to another location in the current document, although any action (see PDF::Action) can be specified.

Bookmark is a utility class used to simplify work with %PDF bookmarks (or outlines; see section 8.2.2 'Document Outline' in %PDF Reference Manual for more details).

Methods


<static> create(in_doc, in_title)

Creates a new valid Bookmark with given title in the specified document.

Parameters:
Name Type Description
in_doc PDFNet.PDFDoc

The document in which a Bookmark is to be created.

in_title string

The title string value of the new Bookmark.

Returns:

A promise that resolves to the new Bookmark.

Type
PDFNet.Bookmark

<static> createFromObj(in_bookmark_dict)

A constructor. Creates a Bookmark and initialize it using given Cos/SDF object.

Parameters:
Name Type Description
in_bookmark_dict PDFNet.Obj

Pointer to the Cos/SDF object (outline item dictionary).

Returns:

A promise that resolves to the new Bookmark.

Type
PDFNet.Bookmark

addChild(in_bookmark)

adds the specified Bookmark as the new last child of this Bookmark.

Parameters:
Name Type Description
in_bookmark PDFNet.Bookmark

The Bookmark object to be added as a last child of this Bookmark.


addNewChild(in_title)

Adds a new Bookmark as the new last child of this Bookmark.

Parameters:
Name Type Description
in_title string

The title string value of the new Bookmark.

Returns:

A promise that resolves to the newly created child Bookmark.

Type
PDFNet.Bookmark

addNewNext(in_title)

Adds a new Bookmark to the tree containing this Bookmark, as the new right sibling.

Parameters:
Name Type Description
in_title string

The title string value of the new Bookmark.

Returns:

A promise that resolves to the newly created sibling Bookmark.

Type
PDFNet.Bookmark

addNewPrev(in_title)

Adds a new Bookmark to the tree containing this Bookmark, as the new left sibling.

Parameters:
Name Type Description
in_title string

The title string value of the new Bookmark.

Returns:

A promise that resolves to the newly created sibling Bookmark.

Type
PDFNet.Bookmark

addNext(in_bookmark)

adds the specified Bookmark as the new right sibling to this Bookmark, adjusting the tree containing this Bookmark appropriately.

Parameters:
Name Type Description
in_bookmark PDFNet.Bookmark

The Bookmark object to be added to this Bookmark.


addPrev(in_bookmark)

adds the specified Bookmark as the new left sibling to this Bookmark, adjusting the tree containing this Bookmark appropriately.

Parameters:
Name Type Description
in_bookmark PDFNet.Bookmark

The Bookmark object to be added to this Bookmark.


compare(in_bookmark)

Compares two Bookmark objects for equality.

Parameters:
Name Type Description
in_bookmark PDFNet.Bookmark

A reference to an existing Bookmark object.

Returns:

A promise that resolves to true if the both Bookmarks share the same underlying SDF/Cos object; otherwise false.

Type
boolean

copy()

Copy Constructor. Creates a new Bookmark object equal to the existing Bookmark object.

Returns:

A promise that resolves to a new Bookmark object.

Type
PDFNet.Bookmark

delete()

removes the Bookmark's subtree from the bookmark tree containing it.


find(in_title)

Returns the Bookmark specified by the given title string.

Parameters:
Name Type Description
in_title string

The title string value of the Bookmark to find.

Returns:

A promise that resolves to a Bookmark matching the title string value specified.

Type
PDFNet.Bookmark

getAction()

Returns the Bookmark's action.

Returns:

A promise that resolves to the Bookmark's action.

Type
PDFNet.Action

getColor()

Returns the Bookmark's RGB color value.


getFirstChild()

Returns the Bookmark's first child.

Returns:

A promise that resolves to the Bookmark's first child.

Type
PDFNet.Bookmark

getFlags()

Returns the Bookmark's flags.

Returns:

A promise that resolves to the flags of the Bookmark object. Bit 1 (least-significant bit) indicates italic font whereas bit 2 indicates bold font. Therefore, 0 indicates normal, 1 is italic, 2 is bold, and 3 is bold-italic.

Type
number

getIndent()

Returns the indentation level of the Bookmark in its containing tree.

Returns:

A promise that resolves to the indentation level of the Bookmark in its containing tree.

Type
number

getLastChild()

Returns the Bookmark's last child.

Returns:

A promise that resolves to the Bookmark's last child.

Type
PDFNet.Bookmark

getNext()

Returns the Bookmark's next (right) sibling.

Returns:

A promise that resolves to the Bookmark's next (right) sibling.

Type
PDFNet.Bookmark

getOpenCount()

Returns the number of opened bookmarks in this subtree.

Returns:

A promise that resolves to the number of opened bookmarks in this subtree (not including this Bookmark). If the item is closed, a negative integer whose absolute value specifies how many descendants would appear if the item were reopened.

Type
number

getParent()

Returns the Bookmark's parent Bookmark.

Returns:

A promise that resolves to the Bookmark's parent Bookmark.

Type
PDFNet.Bookmark

getPrev()

Returns the Bookmark's previous (left) sibling.

Returns:

A promise that resolves to the Bookmark's previous (left) sibling.

Type
PDFNet.Bookmark

getSDFObj()

Returns the underlying SDF/Cos object.

Returns:

A promise that resolves to the underlying SDF/Cos object.

Type
PDFNet.Obj

getTitle()

Returns the Bookmark's title string.

Returns:

A promise that resolves to the Bookmark's title string).

Type
string

getTitleObj()

Returns the Bookmark's title string object.

Returns:

A promise that resolves to the Bookmark's title string object.

Type
PDFNet.Obj

hasChildren()

Indicates whether the Bookmark has children.

Returns:

A promise that resolves to true if the Bookmark has children; otherwise false.

Type
boolean

isOpen()

Indicates whether the Bookmark is open.

Returns:

A promise that resolves to true if this Bookmark is open; otherwise false.

Type
boolean

isValid()

Indicates whether the Bookmark is valid (non-null).

Returns:

A promise that resolves to true if this is a valid (non-null) Bookmark; otherwise false.

Type
boolean

removeAction()

removes the Bookmark's action.


setAction(in_action)

sets the Bookmark's action.

Parameters:
Name Type Description
in_action PDFNet.Action

The new Action for the Bookmark.


setColor(in_r, in_g, in_b)

Sets the Bookmark's color value.

Parameters:
Name Type Description
in_r number

The red component of the color.

in_g number

The green component of the color.

in_b number

The blue component of the color.


setFlags(in_flags)

Sets the Bookmark's flags.

Parameters:
Name Type Description
in_flags number

The new bookmark flags. Bit 1 (the least-significant bit) indicates italic font whereas bit 2 indicates bold font. Therefore, 0 indicates normal, 1 is italic, 2 is bold, and 3 is bold-italic.


setOpen(in_open)

Opens or closes the Bookmark.

Parameters:
Name Type Description
in_open boolean

Boolean value that contains the status. If true, the Bookmark is opened. Otherwise the Bookmark is closed.


setTitle(title)

Sets the Bookmark's title string.

Parameters:
Name Type Description
title string

The new title string for the bookmark.


unlinks this Bookmark from the bookmark tree that contains it, and adjusts the tree appropriately.