public class

Bookmark

extends Object
java.lang.Object
   ↳ com.pdftron.pdf.Bookmark

Class Overview

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).

Summary

Public Constructors
Bookmark()
A constructor.
Bookmark(Obj in_bookmark_dict)
A constructor.
Public Methods
void addChild(Bookmark in_bookmark)
Adds the specified Bookmark as the new last child of this Bookmark.
Bookmark addChild(String in_title)
Adds a new Bookmark as the new last child of this Bookmark.
Bookmark addNext(String in_title)
Adds a new Bookmark to the tree containing this Bookmark, as the new right sibling.
void addNext(Bookmark in_bookmark)
Adds the specified Bookmark as the new right sibling to this Bookmark, adjusting the tree containing this Bookmark appropriately.
Bookmark addPrev(String in_title)
Adds a new Bookmark to the tree containing this Bookmark, as the new left sibling.
void addPrev(Bookmark in_bookmark)
Adds the specified Bookmark as the new left sibling to this Bookmark, adjusting the tree containing this Bookmark appropriately.
static Bookmark create(PDFDoc in_doc, String in_title)
Creates a new valid Bookmark with given title in the specified document.
void delete()
Removes the Bookmark's subtree from the bookmark tree containing it.
boolean equals(Object b)
Compares two Bookmark objects for equality.
Bookmark find(String in_title)
Get the Bookmark specified by the given title string.
Action getAction()
Get the Bookmark's action.
double[] getColor()
Get the Bookmark's RGB color value.
Bookmark getFirstChild()
Returns the Bookmark's first child.
int getFlags()
Get the Bookmark's flags.
int getIndent()
Get the indentation level of the Bookmark in its containing tree.
Bookmark getLastChild()
Returns the Bookmark's last child.
Bookmark getNext()
Returns the Bookmark's next (right) sibling.
int getOpenCount()
Get the number of opened bookmarks in this subtree.
Bookmark getParent()
Returns the Bookmark's parent Bookmark.
Bookmark getPrev()
Returns the Bookmark's previous (left) sibling.
Obj getSDFObj()
Returns the underlying SDF/Cos object.
String getTitle()
Get the Bookmark's title string.
Obj getTitleObj()
Get the Bookmark's title string object.
boolean hasChildren()
Indicates whether the Bookmark has children.
int hashCode()
boolean isOpen()
Indicates whether the Bookmark is open.
boolean isValid()
Indicates whether the Bookmark is valid (non-null).
void removeAction()
Removes the Bookmark's action.
void setAction(Action in_action)
Set the Bookmark's action.
void setColor(double in_r, double in_g, double in_b)
Set Bookmark's text to specified color in RGB value
void setColor()
Set Bookmark's text to black.
void setFlags(int in_flags)
Set the Bookmark's flags.
void setOpen(boolean in_open)
Open or close the Bookmark.
void setTitle(String title)
Set the Bookmark's title string.
void unlink()
Unlinks this Bookmark from the bookmark tree that contains it, and adjusts the tree appropriately.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Bookmark ()

A constructor. Creates a null (non-valid) bookmark.

public Bookmark (Obj in_bookmark_dict)

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

Note: The constructor does not copy any data, but is instead the logical equivalent of a type cast.

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

Public Methods

public void addChild (Bookmark in_bookmark)

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

Note: Parameter in_bookmark must not be linked to a bookmark tree.

Note: If this Bookmark previously had no children, it will be open after the child is added.

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

public Bookmark addChild (String in_title)

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

Note: If this Bookmark previously had no children, it will be open after the child is added.

Parameters
in_title The title string value of the new Bookmark.
Returns
  • The newly created child Bookmark.

public Bookmark addNext (String in_title)

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

Parameters
in_title The title string value of the new Bookmark.
Returns
  • The newly created sibling Bookmark.

public void addNext (Bookmark in_bookmark)

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

Note: Parameter in_bookmark must not be linked to a bookmark tree.

Parameters
in_bookmark The Bookmark object to be added to this Bookmark.

public Bookmark addPrev (String in_title)

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

Parameters
in_title The title string value of the new Bookmark.
Returns
  • The newly created sibling Bookmark.

public void addPrev (Bookmark in_bookmark)

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

Note: Parameter in_bookmark must not be linked to a bookmark tree.

Parameters
in_bookmark The Bookmark object to be added to this Bookmark.

public static Bookmark create (PDFDoc in_doc, String in_title)

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

Note: The new Bookmark is not linked to the outline tree. Use AddChild()/AddNext()/AddPrev() methods in order to link the Bookmark to the outline tree

Parameters
in_doc The document in which a Bookmark is to be created.
in_title The title string value of the new Bookmark.
Returns
  • The new Bookmark.

public void delete ()

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

public boolean equals (Object b)

Compares two Bookmark objects for equality.

Parameters
b the b
Returns
  • True if the both Bookmarks share the same underlying SDF/Cos object; otherwise false.

public Bookmark find (String in_title)

Get the Bookmark specified by the given title string.

Parameters
in_title The title string value of the Bookmark to find.
Returns
  • A Bookmark matching the title string value specified.

public Action getAction ()

Get the Bookmark's action.

Returns
  • The bookmark's action.

public double[] getColor ()

Get the Bookmark's RGB color value.

Note: The three numbers out_r, out_g, and out_b are in the range 0.0 to 1.0, representing the components in the DeviceRGB color space of the color to be used for the Bookmark's text. double red, green, blue; bookmark.GetColor(red, green, blue);

Returns
  • RGB color value in a array

public Bookmark getFirstChild ()

Returns the Bookmark's first child.

Returns
  • The Bookmark's first child.

public int getFlags ()

Get the Bookmark's flags.

Returns
  • 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.

public int getIndent ()

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

Note: The root level has an indentation level of zero.

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

public Bookmark getLastChild ()

Returns the Bookmark's last child.

Returns
  • The Bookmark's last child.

public Bookmark getNext ()

Returns the Bookmark's next (right) sibling.

Returns
  • The Bookmark's next (right) sibling.

public int getOpenCount ()

Get the number of opened bookmarks in this subtree.

Returns
  • 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.

public Bookmark getParent ()

Returns the Bookmark's parent Bookmark.

Returns
  • The Bookmark's parent Bookmark.

public Bookmark getPrev ()

Returns the Bookmark's previous (left) sibling.

Returns
  • The Bookmark's previous (left) sibling.

public Obj getSDFObj ()

Returns the underlying SDF/Cos object.

Note: A null (non-valid) bookmark returns a null object.

Returns
  • The underlying SDF/Cos object.

public String getTitle ()

Get the Bookmark's title string.

Returns
  • The Bookmark's title string).

public Obj getTitleObj ()

Get the Bookmark's title string object.

Returns
  • The Bookmark's title string object.

public boolean hasChildren ()

Indicates whether the Bookmark has children.

Returns
  • True if the Bookmark has children; otherwise false.

public int hashCode ()

public boolean isOpen ()

Indicates whether the Bookmark is open.

Note: An open Bookmark shows all its children.

Returns
  • True if this Bookmark is open; otherwise false.

public boolean isValid ()

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

Note: If this method returns false the underlying SDF/Cos object is null and the Bookmark object should be treated as null as well.

Returns
  • True if this is a valid (non-null) Bookmark; otherwise false.

public void removeAction ()

Removes the Bookmark's action.

public void setAction (Action in_action)

Set the Bookmark's action.

Parameters
in_action The new Action for the Bookmark.

public void setColor (double in_r, double in_g, double in_b)

Set Bookmark's text to specified color in RGB value

Parameters
in_r the red component in the DeviceRGB color space
in_g the green component in the DeviceRGB color space
in_b the blue component in the DeviceRGB color space

public void setColor ()

Set Bookmark's text to black.

public void setFlags (int in_flags)

Set the Bookmark's flags.

Parameters
in_flags 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.

public void setOpen (boolean in_open)

Open or close the Bookmark.

Note: An opened Bookmark shows its children, while a closed Bookmark does not.

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

public void setTitle (String title)

Set the Bookmark's title string.

Parameters
title The new title string for the bookmark.

public void unlink ()

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

Note: After the bookmark is unlinked is can be moved to another place in the bookmark tree located in the same document.