Detect Changes in PDF Bookmarks

Managing bookmarks from your code or from the bookmarks sidebar UI will trigger events you can listen to. The BookmarksChangeEvent gets triggered whenever a bookmark is created, updated, or deleted:

instance.addEventListener("bookmarks.change", () => {
  console.log("Your bookmarks changed!");
});

If you want more information about how exactly a bookmark has changed, there are several other more fine-grained events you can listen to. You’ll find more details about this in the API docs: