Bookmark metadata value that is programmatically accessible in WebViewer

WebViewer Version:

Do you have an issue with a specific file(s)?


Can you reproduce using one of our samples or online demos?


Are you using the WebViewer server?


Does the issue only happen on certain browsers?


Is your issue related to a front-end framework?


Is your issue related to annotations?


Please give a brief summary of your issue:
(Think of this as an email subject)

is there any property or method I could use to set a value in a Bookmark and have it accessible in the WebViewer DOM when the PDF loads without the user seeing this metadata value? It appears the only thing I can think of is “Bookmark.SetTitle(”“)”, however I dont want to change the title of my bookmarks.

The next thing I thought of was using using

var action = pdftron.PDF.Action.CreateURI(doc, “#Whatever content I want”);

I did the above in a backend process and saved the PDF before viewing in WebViewer.

So that later when I click the Bookmark in the Outline Panel, I should see the error in the Web Browser Console - following that I tried using “window.onerror”, but it does not appear to be working with the WebViewer (the reason I wanted this is to pull the error message from the Web Browser Console and get the metadata string I wanted).

Do you know how to get “window.onerror” to return an error from the Web Console upon clicking a Bookmark in the Outline Panel (because CreateUri was set to “#”)? I am trying to do this in Typescript.

Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)

Please provide a link to a minimal sample where the issue is reproducible:

Hi action.jaxzon,

Using setAction to store a metadata string for outline bookmarks should work as a workaround. But please be aware that clicking on said outline will not do anything, as the metadata string is not a valid URL.

The following code works for me:

const { documentViewer, PDFNet } = instance.Core;
await PDFNet.initialize();

// to add outline after document is loaded
documentViewer.addEventListener('documentLoaded', async () => {
  const doc = documentViewer.getDocument();
  const pdfDoc = await doc.getPDFDoc();
  const myitem = await PDFNet.Bookmark.create(pdfDoc, 'My outline item');

  const action = await PDFNet.Action.createURI(pdfDoc, 'My outline metadata');
  await myitem.setAction(action);
  await pdfDoc.addRootBookmark(myitem);

When the newly created outline is clicked on, this is what I’m seeing in the devtool:

Please find below relevant documentation:

Hope this helps!

Maggie V.