Foxit PDF SDK

Public Member Functions | Static Public Attributes | List of all members
FSDK.Bookmark Class Reference

## Public Member Functions
| constructor (pdf_doc, bookmark_dict)
| Constructor, with parameters. More...
| GetAction ()
| Get action. More...
| GetColor ()
| Get the color used for displaying title. More...
| GetDestination ()
| Get the destination. More...
| GetDict ()
| Get PDF dictionary of current bookmark. More...
| GetFirstChild ()
| Get the first child bookmark. More...
| GetNextSibling ()
| Get the next sibling bookmark. More...
| GetParent ()
| Get the parent bookmark. More...
| GetStyle ()
| Get the style. More...
| GetTitle ()
| Get the title. More...
| HasChild ()
| Check if current bookmark has child bookmark(s). More...
| Insert (title, position)
| Insert a new bookmark according to the relationship position to current bookmark. More...
| IsEmpty ()
| Check whether current object is empty or not. More...
| IsFirstChild ()
| Check if current bookmark is the first child of its parent bookmark. More...
| IsLastChild ()
| Check if current bookmark is the last child of its parent bookmark. More...
| IsRoot ()
| Check if current bookmark is the root bookmark. More...
| MoveTo (dest_bookmark, position)
| Move current bookmark to be child or sibling of another bookmark. More...
| RemoveAction ()
| Remove action. More...
| SetAction (action)
| Set action. More...
| SetColor (color)
| Set the color used for displaying title. More...
| SetDestination (destination)
| Set the destination. More...
| SetStyle (style)
| Set the style. More...
| SetTitle (title)
| Set the title. More...

## Static Public Attributes
static | e_PosFirstChild
| Enumeration for bookmark position. More...
static | e_PosFirstSiblingv
| A bookmark is the first sibling of another specified bookmark.
static | e_PosLastChild
| A bookmark is the last child of another specified bookmark.
static | e_PosLastSibling
| A bookmark is the last sibling of another specified bookmark.
static | e_PosNextSibling
| A bookmark is the next sibling of another specified bookmark.
static | e_PosPrevSibling
| A bookmark is the previous sibling of another specified bookmark.
static | e_StyleBold
| Show bookmark title as bold text.
static | e_StyleItalic
| Show bookmark title as italic text.
static | e_StyleNormal
| Enumeration for bookmark style type. More...

## 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 FSDK.PDFDoc.GetRootBookmark must be called first to get the root of the whole bookmark tree. If the "root bookmark" does not exist, function FSDK.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 FSDK.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 FSDK.Bookmark.GetParent.
- To access the first child bookmark, use function FSDK.Bookmark.GetFirstChild.
- To access the next sibling bookmark, use function FSDK.Bookmark.GetNextSibling.
- To Insert a new bookmark, use function FSDK.Bookmark.Insert.
- To move a bookmark, use function FSDK.Bookmark.MoveTo.

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

See also
  FSDK.PDFDoc

## Member Function Documentation

## ◆ constructor()

FSDK.Bookmark.constructor | ( | pdf_doc | ,
|  | bookmark_dict |
| ) |  |

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.

## ◆ GetAction()

FSDK.Bookmark.GetAction | ( |  | ) |

Get action.

If current bookmark is returned by function FSDK.PDFDoc.GetRootBookmark or FSDK.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 FSDK.Action.IsEmpty returns true.

Returns
  An action object.

## ◆ GetColor()

FSDK.Bookmark.GetColor | ( |  | ) |

Get the color used for displaying title.

If current bookmark is returned by function FSDK.PDFDoc.GetRootBookmark or FSDK.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()

FSDK.Bookmark.GetDestination | ( |  | ) |

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 FSDK.Destination.IsEmpty returns true.
If current bookmark is returned by function FSDK.PDFDoc.GetRootBookmark or FSDK.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 FSDK.Destination.IsEmpty returns true.

Returns
  The destination object.

## ◆ GetDict()

FSDK.Bookmark.GetDict | ( |  | ) |

Get PDF dictionary of current bookmark.

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

## ◆ GetFirstChild()

FSDK.Bookmark.GetFirstChild | ( |  | ) |

Get the first child bookmark.

Returns
  The first child bookmark object.

## ◆ GetNextSibling()

FSDK.Bookmark.GetNextSibling | ( |  | ) |

Get the next sibling bookmark.

If current bookmark is returned by function FSDK.PDFDoc.GetRootBookmark or FSDK.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 FSDK.Bookmark.IsEmpty returns true.

Returns
  The next sibling bookmark object.

## ◆ GetParent()

FSDK.Bookmark.GetParent | ( |  | ) |

Get the parent bookmark.

If current bookmark is returned by function FSDK.PDFDoc.GetRootBookmark or FSDK.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 FSDK.Bookmark.IsEmpty returns true.

Returns
  The parent bookmark object.

## ◆ GetStyle()

FSDK.Bookmark.GetStyle | ( |  | ) |

Get the style.

If current bookmark is returned by function FSDK.PDFDoc.GetRootBookmark or FSDK.PDFDoc.CreateRootBookmark, that means it is the "root bookmark", and it does not have style information. In this case, this function will return FSDK.Bookmark.e_StyleNormal by default.

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

## ◆ GetTitle()

FSDK.Bookmark.GetTitle | ( |  | ) |

Get the title.

If current bookmark is returned by function FSDK.PDFDoc.GetRootBookmark or FSDK.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()

FSDK.Bookmark.HasChild | ( |  | ) |

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

FSDK.Bookmark.Insert | ( | title | ,
|  | position |
| ) |  |

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 FSDK.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 FSDK.Bookmark.e_PosFirstChild and this should be one of these values. If current bookmark is just the "root bookmark", parameter position can only be FSDK.Bookmark.e_PosFirstChild or FSDK.Bookmark.e_PosLastChild.

Returns
  A new bookmark object.

## ◆ IsEmpty()

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

FSDK.Bookmark.IsFirstChild | ( |  | ) |

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

FSDK.Bookmark.IsLastChild | ( |  | ) |

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

FSDK.Bookmark.IsRoot | ( |  | ) |

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

FSDK.Bookmark.MoveTo | ( | dest_bookmark | ,
|  | position |
| ) |  |

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

If current bookmark is returned by function FSDK.PDFDoc.GetRootBookmark or FSDK.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 FSDK.Bookmark.e_PosFirstChild and this should be one of these values.

Returns
  true means success, while false means failure.

## ◆ RemoveAction()

FSDK.Bookmark.RemoveAction | ( |  | ) |

Remove action.

When removing bookmark's action, bookmark's destination will be removed at the same time.
If current bookmark is returned by function FSDK.PDFDoc.GetRootBookmark or FSDK.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()

FSDK.Bookmark.SetAction | ( | action |  | ) |

Set action.

If current bookmark is returned by function FSDK.PDFDoc.GetRootBookmark or FSDK.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: FSDK.Action.e_TypeGoto, FSDK.Action.e_TypeURI, FSDK.Action.e_TypeJavaScript, FSDK.Action.e_TypeNamed, FSDK.Action.e_TypeGoToR, FSDK.Action.e_TypeGoToE, FSDK.Action.e_TypeSubmitForm, FSDK.Action.e_TypeResetForm, FSDK.Action.e_TypeHide, FSDK.Action.e_TypeLaunch, FSDK.Action.e_TypeImportData, FSDK.Action.e_TypeRendition.

Returns
  None.

## ◆ SetColor()

FSDK.Bookmark.SetColor | ( | color |  | ) |

Set the color used for displaying title.

If current bookmark is returned by function FSDK.PDFDoc.GetRootBookmark or FSDK.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()

FSDK.Bookmark.SetDestination | ( | destination |  | ) |

Set the destination.

Bookmark's destination is some place in current document where the bookmark can "goto".
If current bookmark is returned by function FSDK.PDFDoc.GetRootBookmark or FSDK.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()

FSDK.Bookmark.SetStyle | ( | style |  | ) |

Set the style.

If current bookmark is returned by function FSDK.PDFDoc.GetRootBookmark or FSDK.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 FSDK.Bookmark.e_StyleNormal and this can be one or a combination of these values. If the style is invalid, FSDK.Bookmark.e_StyleNormal will be set by default.

Returns
  None.

## ◆ SetTitle()

FSDK.Bookmark.SetTitle | ( | title |  | ) |

Set the title.

If current bookmark is returned by function FSDK.PDFDoc.GetRootBookmark or FSDK.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.

## Member Data Documentation

## ◆ e_PosFirstChild

FSDK.Bookmark.e_PosFirstChild
| static

Enumeration for bookmark position.

Values of this enumeration should be used alone.
Actually, "bookmark position" means the relationship between a bookmark and another bookmark.

A bookmark is the first child of another specified bookmark.

## ◆ e_StyleNormal

FSDK.Bookmark.e_StyleNormal
| static

Enumeration for bookmark style type.

Values of this enumeration can be used alone or in combination.

Show bookmark title as normal text.