Open and Close Bookmark pane programmatically

3 May 20241 minute to read

The PDF Viewer library allows you to open the Bookmark pane programmatically using the openBookmarkPane() method.

The following steps are used to open the Bookmark.

Step 1: Follow the steps provided in the link to create a simple PDF Viewer sample.

Step 2: Insert the following code snippet to implement the functionality for opening the Bookmark pane:

<button id="openBookmark">Open Bookmark Pane</button>
document.getElementById('openBookmark').addEventListener('click', () => {
  // Open Bookmark pane
  viewer.bookmarkViewModule.openBookmarkPane();
});

Similarly, to close the Bookmark pane programmatically, employ the following code snippet:

<button id="closeBookmark">Close Bookmark Pane</button>

```js
document.getElementById(‘closeBookmark’).addEventListener(‘click’, () => {
// close Bookmark pane
viewer.bookmarkViewModule.closeBookmarkPane();
});

View sample in GitHub