PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
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.
This example shows how to get the bookmarks list:
List<CPDFBookmark> bookmarkList = document.getBookmarks();The steps for adding a new bookmark are as follows:
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 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);Determine whether a bookmark exists on the specified page index. Page indexes are zero-based.
boolean hasBookmark = document.hasBookmark(pageIndex);