How to open a document at a specific page?

WebViewer Version: 8.3.3

Do you have an issue with a specific file(s)? All
Can you reproduce using one of our samples or online demos? Not verified
Are you using the WebViewer server? No
Does the issue only happen on certain browsers? No
Is your issue related to a front-end framework? No
Is your issue related to annotations? No

Please describe your issue and provide steps to reproduce it:

I need to reload the file multiple times and I call loadDocument method from WebViewer.
The problem is that every time the file is reloaded it jumps to the first page of the file.
I need to remain on the page that I was working on before reload.
Can I specify which page to be opened when the file reloads?

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

The easiest way to do it :

  • on exit (window:beforeunload) / before reload : save the current page in the localstorage
let currentPage = this.wvInstance.Core.documentViewer.getCurrentPage();
localStorage.setItem(this.wvInstance.Core.documentViewer.getDocument().getDocumentId(), (currentPage.toString()));
  • when loading a document, set the current page based on the documentId. here is an example :
documentViewer.addEventListener('documentLoaded', async () => {
          
          //Set current page if in cache
          if(documentViewer.getDocument()!=null && documentViewer.getDocument().getDocumentId()!=null) {
            let currentDocPage =  localStorage.getItem(documentViewer.getDocument().getDocumentId());
            if(currentDocPage!=null) {
              documentViewer.setCurrentPage(parseInt(currentDocPage),true);
            }
          }
       
      });