Guides
Bookmarks
Bookmarks are a convenient navigation tool in PDF documents that allow users to quickly jump to specific pages or locations within the document. Bookmarks are typically displayed in a sidebar or panel of the document reader, allowing users to quickly access related content by clicking on them. Bookmarks can be added manually or automatically generated based on the document structure.
Get Bookmarks
tsx
const bookmarks = await pdfReaderRef.current?._pdfDocument.getBookmarks();Add Bookmark
tsx
const title = 'Chapter 1';
const pageIndex = 2;
const addResult = await pdfReaderRef.current?._pdfDocument.addBookmark(title, pageIndex);Edit Bookmark
tsx
const bookmarks = await pdfReaderRef.current?._pdfDocument.getBookmarks();
if (bookmarks.length > 0) {
const bookmark = bookmarks[0];
bookmark.setTitle('Updated Title');
const updateResult = await pdfReaderRef.current?._pdfDocument.updateBookmark(bookmark);
}Delete Bookmark
tsx
const pageIndex = 0;
const removeResult = await pdfReaderRef.current?._pdfDocument.removeBookmark(pageIndex);Check if Bookmark Exists
tsx
const pageIndex = 0;
const hasBookmark = await pdfReaderRef.current?._pdfDocument.hasBookmark(pageIndex);