Structured bookmarks are a way to help you navigate PDF documents systematically. Each bookmark in a PDF document leads you to a different view or page in the document. Right PDF SDK provides APIs to generate bookmarks, remove them from a document, configure properties, and detect if a certain bookmark is valid or not. Here are some common bookmark APIs listed in Table 3.4. For a complete list of APIs for PDF bookmarks, please refer to ZSBookmark.h.

Table 3.4

  API Name Description
1 ZSDoc_GetBookmarkRoot Get the root node of a bookmark in a PDF document object.
Get a valid bookmark even if the bookmark tree is empty.
2 ZSBookmark_IsValid Detect whether a bookmark is a valid or not.
3 ZSBookmark_GetParent Get the parent node of a bookmark.
4 ZSBookmark_GetFirstChild Get the first (leftest) node of a bookmark.
5 ZSBookmark_GetPrevSibling Get the previous sibling node of a bookmark.
6 ZSBookmark_HasChild Detect whether a bookmark has a child bookmark or not.
7 ZSBookmark_IsOpen Detect whether a bookmark is open or not. An open node shows all its children nodes.
8 ZSBookmark_GetFlags Get current bookmark’s flags, defined by ZSBOOKMARK_FONT_XXX.
9 ZSBookmark_GetTitle Get the current bookmark’s title.
10 ZSBookmark_AddChild Add a bookmark and all its children into a bookmark tree as a child node.
11 ZSBookmark_Remove Remove a bookmark and all its children from the bookmark tree.
12 ZSBookmark_SetOpen Set a bookmark’s open/ close state.
13 ZSBookmark_SetAction Set a bookmark action.
14 ZSBookmark_NumActions Get a count of bookmark actions.
15 ZSBookmark_RemoveAction Remove a specific bookmark action.
16 ZSBookmark_RemoveAllActions Remove all bookmark actions.

 


This is an example of adding and deleting bookmarks.

Example: Add and delete bookmarks

ZSDoc_GetBookmarkRoot(doc, &bookmark);

//Add
ZS_BSTRC(title, “New Bookmark”);
ZSBookmark_AddNewChild(bookmark, &title, &child);
//Set a custom action
ZSBookmark_InsertAction(child, 0, &action);

//Properties
ZSBookmark_SetColor(child, ZSARGB_MAKE(255, 0, 0));
ZSBookmark_SetFlags(child, ZSBOOKMARK_FONT_BOLD);

//Delete
ZSBookmark_Remove(child);