Bookmarks
Bookmarks are manually added location markers that help you quickly navigate to specific positions in a document. Unlike outlines, bookmarks usually reflect personalized points of interest during reading and support operations such as creation, retrieval, and deletion.
Get the Bookmark List
This example shows how to get the bookmarks list:
List<CPDFBookmark> bookmarkList = document.getBookmarks();Add a New Bookmark
The steps for adding a new bookmark are as follows:
- Create a bookmark object.
- Set bookmark properties.
- Add the bookmark to the document.
This example shows how to add a new bookmark:
// Page indexes are zero-based, so 4 refers to page 5.
int pageIndex = 4;
// Create a bookmark object and set its properties.
CPDFBookmark bookmark = new CPDFBookmark(pageIndex, "new bookmark", CPDFDate.toStandardDate(TTimeUtil.getCurrentDate()));
// Add the bookmark to the document.
document.addBookmark(bookmark);// Page indexes are zero-based, so 4 refers to page 5.
val pageIndex = 4
// Create a bookmark object and set its properties.
val bookmark = CPDFBookmark(
pageIndex,
"new bookmark",
CPDFDate.toStandardDate(TTimeUtil.getCurrentDate())
)
// Add the bookmark to the document.
document.addBookmark(bookmark)Delete a Bookmark
Delete the bookmark for a specified page index. Page indexes are zero-based.
This example shows how to delete a bookmark:
// Delete the bookmark for the first page.
document.removeBookmark(0);Check Whether a Bookmark Exists
Determine whether a bookmark exists on the specified page index. Page indexes are zero-based.
boolean hasBookmark = document.hasBookmark(pageIndex);