Foxit PDF SDK

Public Member Functions | Static Public Attributes | List of all members
com.foxit.sdk.pdf.Bookmark Class Reference
Inheritance diagram for com.foxit.sdk.pdf.Bookmark:

## Public Member Functions
| Bookmark (PDFDoc pdf_doc, PDFDictionary bookmark_dict) throws com.foxit.sdk.PDFException
| Constructor, with parameters. More...
| Bookmark (Bookmark other)
| Constructor, with another bookmark object. More...
synchronized void | delete ()
| Clean up related C++ resources immediately. More...
Action | getAction () throws com.foxit.sdk.PDFException
| Get action. More...
long | getColor () throws com.foxit.sdk.PDFException
| Get the color used for displaying title. More...
Destination | getDestination () throws com.foxit.sdk.PDFException
| Get the destination. More...
PDFDictionary | getDict () throws com.foxit.sdk.PDFException
| Get PDF dictionary of current bookmark. More...
Bookmark | getFirstChild () throws com.foxit.sdk.PDFException
| Get the first child bookmark. More...
Bookmark | getNextSibling () throws com.foxit.sdk.PDFException
| Get the next sibling bookmark. More...
Bookmark | getParent () throws com.foxit.sdk.PDFException
| Get the parent bookmark. More...
int | getStyle () throws com.foxit.sdk.PDFException
| Get the style. More...
String | getTitle () throws com.foxit.sdk.PDFException
| Get the title. More...
boolean | hasChild () throws com.foxit.sdk.PDFException
| Check if current bookmark has child bookmark(s). More...
Bookmark | insert (String title, int position) throws com.foxit.sdk.PDFException
| Insert a new bookmark according to the relationship position to current bookmark. More...
boolean | isEmpty ()
| Check whether current object is empty or not. More...
boolean | isFirstChild () throws com.foxit.sdk.PDFException
| Check if current bookmark is the first child of its parent bookmark. More...
boolean | isLastChild () throws com.foxit.sdk.PDFException
| Check if current bookmark is the last child of its parent bookmark. More...
boolean | isRoot () throws com.foxit.sdk.PDFException
| Check if current bookmark is the root bookmark. More...
boolean | moveTo (Bookmark dest_bookmark, int position) throws com.foxit.sdk.PDFException
| Move current bookmark to be child or sibling of another bookmark. More...
boolean | removeAction () throws com.foxit.sdk.PDFException
| Remove action. More...
void | setAction (Action action) throws com.foxit.sdk.PDFException
| Set action. More...
void | setColor (long color) throws com.foxit.sdk.PDFException
| Set the color used for displaying title. More...
void | setDestination (Destination destination) throws com.foxit.sdk.PDFException
| Set the destination. More...
void | setStyle (int style) throws com.foxit.sdk.PDFException
| Set the style. More...
void | setTitle (String title) throws com.foxit.sdk.PDFException
| Set the title. More...
Public Member Functions inherited from com.foxit.sdk.common.Base
synchronized void | delete ()
| Clean up related C++ resources immediately. More...

## Static Public Attributes
static final int | e_PosFirstChild = 0
| A bookmark is the first child of another specified bookmark.
static final int | e_PosFirstSibling = 4
| A bookmark is the first sibling of another specified bookmark.
static final int | e_PosLastChild = 1
| A bookmark is the last child of another specified bookmark.
static final int | e_PosLastSibling = 5
| A bookmark is the last sibling of another specified bookmark.
static final int | e_PosNextSibling = 3
| A bookmark is the next sibling of another specified bookmark.
static final int | e_PosPrevSibling = 2
| A bookmark is the previous sibling of another specified bookmark.
static final int | e_StyleBold = 0x02
| Show bookmark title as bold text.
static final int | e_StyleItalic = 0x01
| Show bookmark title as italic text.
static final int | e_StyleNormal = 0x00
| Show bookmark title as normal text.

## Detailed Description

PDF bookmark is also called "outline". It's a tree-structured hierarchy. It allows user to navigate PDF document easily by selecting a bookmark. One bookmark contains a destination or actions to indicate how to response when user selects it.
In order to get/set the bookmark tree, function PDFDoc.getRootBookmark must be called first to get the root of the whole bookmark tree. If the "root bookmark" does not exist, function PDFDoc.createRootBookmark could be called to create a new "root bookmark". Here, "root bookmark" is an abstract object. It represents the "Outline" of PDF document. For more details about "Outline", please refer to Section 8.2.3 in PDF Reference 1.7. "root bookmark" can only have some child bookmarks, but no parent, no next sibling bookmarks or any data (including bookmark data, destination data and action data). And "root bookmark" cannot be shown on the application UI since it has no data. So, for a root bookmark, only function Bookmark.getFirstChild can be used.
From the root bookmark, the bookmark tree can be traversed and each bookmark node can be accessed.
This class offers several functions to get/set other bookmarks from current bookmark. For example:

- To access the parent bookmark, use function Bookmark.getParent .

- To access the first child bookmark, use function Bookmark.getFirstChild .

- To access the next sibling bookmark, use function Bookmark.getNextSibling .

- To Insert a new bookmark, use function Bookmark.insert .

- To move a bookmark, use function Bookmark.moveTo .

This class also offers functions to get/set the data of a PDF bookmark.

See also
  PDFDoc

## Constructor & Destructor Documentation

## ◆ Bookmark() [1/2]

com.foxit.sdk.pdf.Bookmark.Bookmark | ( | PDFDoc | pdf_doc,
|  | PDFDictionary | bookmark_dict
| ) |  | throws com.foxit.sdk.PDFException

Constructor, with parameters.

Parameters

  [in] | pdf_doc | A valid PDF document object.
  [in] | bookmark_dict | A PDF dictionary which represents a bookmark. This PDF dictionary should have existed in the PDF document represented by parameter pdf_doc.

## ◆ Bookmark() [2/2]

com.foxit.sdk.pdf.Bookmark.Bookmark | ( | Bookmark | other | ) |

Constructor, with another bookmark object.

Parameters

  [in] | other | Another bookmark object.

## Member Function Documentation

## ◆ delete()

synchronized void com.foxit.sdk.pdf.Bookmark.delete | ( |  | ) |

Clean up related C++ resources immediately.

Returns
  None.

Note
  Once this function is called, current object cannot be used anymore.

## ◆ getAction()

Action com.foxit.sdk.pdf.Bookmark.getAction | ( |  | ) | throws com.foxit.sdk.PDFException

Get action.

If current bookmark is returned by function PDFDoc.getRootBookmark or PDFDoc.createRootBookmark , that means it is the "root bookmark", and it does not have any action information. In this case, this function will return an action object which's function actions.Action.isEmpty returns true.

Returns
  An action object.

## ◆ getColor()

long com.foxit.sdk.pdf.Bookmark.getColor | ( |  | ) | throws com.foxit.sdk.PDFException

Get the color used for displaying title.

If current bookmark is returned by function PDFDoc.getRootBookmark or PDFDoc.createRootBookmark , that means it is the "root bookmark", and it does not have color. In this case, this function will return 0x000000 by default.

Returns
  The color used for displaying title. Format: 0xRRGGBB.

## ◆ getDestination()

Destination com.foxit.sdk.pdf.Bookmark.getDestination | ( |  | ) | throws com.foxit.sdk.PDFException

Get the destination.

Bookmark's destination is some place in current document where the bookmark can "goto". If the bookmark cannot "goto" any place in current document, that means no destination information can be retrieved and this function will return a destination object which's function Destination.isEmpty returns true.
If current bookmark is returned by function PDFDoc.getRootBookmark or PDFDoc.createRootBookmark , that means it is the "root bookmark", and it does not have any destination information. In this case, this function will return a destination object which's function Destination.isEmpty returns true.

Returns
  The destination object.

## ◆ getDict()

PDFDictionary com.foxit.sdk.pdf.Bookmark.getDict | ( |  | ) | throws com.foxit.sdk.PDFException

Get PDF dictionary of current bookmark.

Returns
  The PDF dictionary. If there is any error, this function will return null.

## ◆ getFirstChild()

Bookmark com.foxit.sdk.pdf.Bookmark.getFirstChild | ( |  | ) | throws com.foxit.sdk.PDFException

Get the first child bookmark.

Returns
  The first child bookmark object.

## ◆ getNextSibling()

Bookmark com.foxit.sdk.pdf.Bookmark.getNextSibling | ( |  | ) | throws com.foxit.sdk.PDFException

Get the next sibling bookmark.

If current bookmark is returned by function PDFDoc.getRootBookmark or PDFDoc.createRootBookmark , that means it is the "root bookmark", and it does not have any sibling bookmark. In this case, this function will return a bookmark object which's function Bookmark.isEmpty returns true.

Returns
  The next sibling bookmark object.

## ◆ getParent()

Bookmark com.foxit.sdk.pdf.Bookmark.getParent | ( |  | ) | throws com.foxit.sdk.PDFException

Get the parent bookmark.

If current bookmark is returned by function PDFDoc.getRootBookmark or PDFDoc.createRootBookmark , that means it is the "root bookmark", and it does not have a parent bookmark. In this case, this function will return a bookmark object which's function Bookmark.isEmpty returns true.

Returns
  The parent bookmark object.

## ◆ getStyle()

int com.foxit.sdk.pdf.Bookmark.getStyle | ( |  | ) | throws com.foxit.sdk.PDFException

Get the style.

If current bookmark is returned by function PDFDoc.getRootBookmark or PDFDoc.createRootBookmark , that means it is the "root bookmark", and it does not have style information. In this case, this function will return com.foxit.sdk.pdf.Bookmark.e_StyleNormal by default.

Returns
  Value for The bookmark style. Please refer to values starting from com.foxit.sdk.pdf.Bookmark.e_StyleNormal and this would be one or a combination of these values.

## ◆ getTitle()

String com.foxit.sdk.pdf.Bookmark.getTitle | ( |  | ) | throws com.foxit.sdk.PDFException

Get the title.

If current bookmark is returned by function PDFDoc.getRootBookmark or PDFDoc.createRootBookmark , that means it is the "root bookmark", and it does not have title. In this case, this function will return an empty string.

Returns
  The title string.

## ◆ hasChild()

boolean com.foxit.sdk.pdf.Bookmark.hasChild | ( |  | ) | throws com.foxit.sdk.PDFException

Check if current bookmark has child bookmark(s).

Returns
  true means current bookmark has child bookmark(s), and false means current bookmark does not have any child bookmark.

## ◆ insert()

Bookmark com.foxit.sdk.pdf.Bookmark.insert | ( | String | title,
|  | int | position
| ) |  | throws com.foxit.sdk.PDFException

Insert a new bookmark according to the relationship position to current bookmark.

For the new bookmark, the color would be 0x000000 and the style would be com.foxit.sdk.pdf.Bookmark.e_StyleNormal by default.

Parameters

  [in] | title | Title string for the new bookmark. It should not be an empty string.
  [in] | position | The position where the new bookmark item is to be inserted, based on current bookmark. Please refer to values starting from com.foxit.sdk.pdf.Bookmark.e_PosFirstChild and this should be one of these values. If current bookmark is just the "root bookmark", parameter position can only be com.foxit.sdk.pdf.Bookmark.e_PosFirstChild or com.foxit.sdk.pdf.Bookmark.e_PosLastChild .

Returns
  A new bookmark object.

## ◆ isEmpty()

boolean com.foxit.sdk.pdf.Bookmark.isEmpty | ( |  | ) |

Check whether current object is empty or not.

When the current object is empty, that means current object is useless.

Returns
  true means current object is empty, while false means not.

## ◆ isFirstChild()

boolean com.foxit.sdk.pdf.Bookmark.isFirstChild | ( |  | ) | throws com.foxit.sdk.PDFException

Check if current bookmark is the first child of its parent bookmark.

Returns
  true means current bookmark is the first child of its parent bookmark, while false means not.

## ◆ isLastChild()

boolean com.foxit.sdk.pdf.Bookmark.isLastChild | ( |  | ) | throws com.foxit.sdk.PDFException

Check if current bookmark is the last child of its parent bookmark.

Returns
  true means current bookmark is the last child of its parent bookmark, while false means not.

## ◆ isRoot()

boolean com.foxit.sdk.pdf.Bookmark.isRoot | ( |  | ) | throws com.foxit.sdk.PDFException

Check if current bookmark is the root bookmark.

"root bookmark" is an abstract object. It represents the "Outline" of PDF document. For more details about "Outline", please refer to Section 8.2.3 in PDF Reference 1.7. "root bookmark" can only have some child bookmarks, but no parent, no next sibling bookmarks or any data (including bookmark data, destination data and action data). And "root bookmark" cannot be shown on the application UI since it has no data.

Returns
  true means current bookmark is the root bookmark, while false means not.

## ◆ moveTo()

boolean com.foxit.sdk.pdf.Bookmark.moveTo | ( | Bookmark | dest_bookmark,
|  | int | position
| ) |  | throws com.foxit.sdk.PDFException

Move current bookmark to be child or sibling of another bookmark.

If current bookmark is returned by function PDFDoc.getRootBookmark or PDFDoc.createRootBookmark , that means it is the "root bookmark", and it cannot be moved to be child or sibling of any bookmark in the bookmark tree. In this case, this function will return false directly.

Parameters

  [in] | dest_bookmark | The destination bookmark. It should not be current bookmark itself or any descendant of current bookmark. Current bookmark will be moved to be child or sibling of the destination bookmark.
  [in] | position | The position where the current bookmark is to be moved to, based on parameter destBookmark. Please refer to values starting from com.foxit.sdk.pdf.Bookmark.e_PosFirstChild and this should be one of these values.

Returns
  true means success, while false means failure.

## ◆ removeAction()

boolean com.foxit.sdk.pdf.Bookmark.removeAction | ( |  | ) | throws com.foxit.sdk.PDFException

Remove action.

When removing bookmark's action, bookmark's destination will be removed at the same time.
If current bookmark is returned by function PDFDoc.getRootBookmark or PDFDoc.createRootBookmark , that means it is the "root bookmark", and it does not have any action information. In this case, this function will return true directly.

Returns
  true means success, while false means failure.

## ◆ setAction()

void com.foxit.sdk.pdf.Bookmark.setAction | ( | Action | action | ) | throws com.foxit.sdk.PDFException

Set action.

If current bookmark is returned by function PDFDoc.getRootBookmark or PDFDoc.createRootBookmark , that means it is the "root bookmark", and it does not have any action information. In this case, this function will return directly without doing anything.

Parameters

  [in] | action | A valid action to be set. Currently only support following types as the new action: com.foxit.sdk.pdf.actions.Action.e_TypeGoto , com.foxit.sdk.pdf.actions.Action.e_TypeURI , com.foxit.sdk.pdf.actions.Action.e_TypeJavaScript , com.foxit.sdk.pdf.actions.Action.e_TypeNamed , com.foxit.sdk.pdf.actions.Action.e_TypeGoToR , com.foxit.sdk.pdf.actions.Action.e_TypeGoToE , com.foxit.sdk.pdf.actions.Action.e_TypeSubmitForm , com.foxit.sdk.pdf.actions.Action.e_TypeResetForm , com.foxit.sdk.pdf.actions.Action.e_TypeHide , com.foxit.sdk.pdf.actions.Action.e_TypeLaunch , com.foxit.sdk.pdf.actions.Action.e_TypeImportData , com.foxit.sdk.pdf.actions.Action.e_TypeRendition .

Returns
  None.

## ◆ setColor()

void com.foxit.sdk.pdf.Bookmark.setColor | ( | long | color | ) | throws com.foxit.sdk.PDFException

Set the color used for displaying title.

If current bookmark is returned by function PDFDoc.getRootBookmark or PDFDoc.createRootBookmark , that means it is the "root bookmark", and it does not have color. In this case, this function will return directly without doing anything.

Parameters

  [in] | color | New color used for displaying title. Format:0xRRGGBB.

Returns
  None.

## ◆ setDestination()

void com.foxit.sdk.pdf.Bookmark.setDestination | ( | Destination | destination | ) | throws com.foxit.sdk.PDFException

Set the destination.

Bookmark's destination is some place in current document where the bookmark can "goto".
If current bookmark is returned by function PDFDoc.getRootBookmark or PDFDoc.createRootBookmark , that means it is the "root bookmark", and it does not have any destination information. In this case, this function will return directly without doing anything.

Parameters

  [in] | destination | A valid destination.

Returns
  None.

## ◆ setStyle()

void com.foxit.sdk.pdf.Bookmark.setStyle | ( | int | style | ) | throws com.foxit.sdk.PDFException

Set the style.

If current bookmark is returned by function PDFDoc.getRootBookmark or PDFDoc.createRootBookmark , that means it is the "root bookmark", and it does not have style information. In this case, this function will return directly without doing anything.

Parameters

  [in] | style | New bookmark style. Please refer to values starting from com.foxit.sdk.pdf.Bookmark.e_StyleNormal and this can be one or a combination of these values. If the style is invalid, com.foxit.sdk.pdf.Bookmark.e_StyleNormal will be set by default.

Returns
  None.

## ◆ setTitle()

void com.foxit.sdk.pdf.Bookmark.setTitle | ( | String | title | ) | throws com.foxit.sdk.PDFException

Set the title.

If current bookmark is returned by function PDFDoc.getRootBookmark or PDFDoc.createRootBookmark , that means it is the "root bookmark", and it does not have title. In this case, this function will return directly without doing anything.

Parameters

  [in] | title | New title string. It should not be an empty string.

Returns
  None.