Document jumps back to first page

We are programmatically setting the current page in WebViewer on the documentLoaded event but after a second WebViewer jumps back to the first page on some files. Why is happening and how can I fix it?

This is likely because the document has an “open” action that sets the current page to the first page. WebViewer includes the action as part of the XFDF data and parses this asynchronously so there might be a bit of a delay before the open action is triggered.

To work around this what you can do is ignore any GoTo open actions that are triggered on the document.

const { Actions, docViewer } = instance;
const onTriggered = Actions.GoTo.prototype.onTriggered;
Actions.GoTo.prototype.onTriggered = function(target, event) {
  if (target === docViewer.getDocument() && === 'Open') {

  onTriggered.apply(this, arguments);
1 Like

When I use this code, I get the following error when someone clicks on a link to another page within the PDF.

       TypeError: Cannot read properties of undefined (reading 'Ls')
    at fa.NS (webviewer-core.min.js:1493:364)
    at aa.onTriggered (webviewer-core.min.js:2084:482)
    at Actions.GoTo.onTriggered (pdfViewer.tsx:219:19)
    at Actions.GoTo.onTriggered (pdfViewer.tsx:219:19)
    at (webviewer-core.min.js:1170:51)
    at aa.<anonymous> (webviewer-core.min.js:1455:334)
    at webviewer-core.min.js:694:164
    at Array.forEach (<anonymous>)
    at h.trigger (webviewer-core.min.js:694:96)
    at aa.Hpa (webviewer-core.min.js:2185:164)
fa @ webviewer-core.min.js:214
(anonymous) @ webviewer-core.min.js:694
h.trigger @ webviewer-core.min.js:694
aa.Hpa @ webviewer-core.min.js:2185
na.Nk @ webviewer-core.min.js:3043
       Uncaught Error: TypeError: Cannot read properties of undefined (reading 'Ls')
    at fa (webviewer-core.min.js:214:301)
    at webviewer-core.min.js:694:194
    at Array.forEach (<anonymous>)
    at h.trigger (webviewer-core.min.js:694:96)
    at aa.Hpa (webviewer-core.min.js:2185:164)
    at na.Nk (webviewer-core.min.js:3043:101)