Load PDF without refresh Webviewer

Hi !
How can we load a new PDF to Webviewer from code without closing the current open annotation?
(Keep the current state of Webviewer)

Hi traderaboy,

What exactly do you mean by the state of WebViewer?
Are you trying to preserve annotations, bookmarks, or panel states? Can you please elaborate?

Best Regards,
Ahmad Moaaz
Software Developer
PDFTron Systems, Inc.
www.pdftron.com

Hi Ahmad
Yes I’m trying to preserve annotations states.
For example, I have opened a PDF and then I select an an annotation. Then maybe I want to load a new PDF. But when I change the PDF, the display returns to its initial state. But I just want the PDF file to change and keep the annotation open.

There is the same problem / behaviour when using the new Tab features.
See : Keeping layout between tabs doesnt work - #20 by dfelix

Hi traderaboy,

So you would like the annotations from one PDF to be transferred to the new one when loading a new document?

If so you can extract the annotations as an XFDF string using this API.
Then call loadDocument to load the new document and use this API to merge the XFDF string onto the new document

Best Regards,
Ahmad Moaaz
Software Developer
PDFTron Systems, Inc.
www.pdftron.com

(If I’m mistaken and it’s strictly about keeping the annotation data, then sorry for hijacking the thread)

I think that the problem or behaviour that traderaboy tries to explain is that the annotation component is being “unloaded” when loading a new document.
The user has to click on it again for it to show, while it was previously opened for the previous document.

One way for it to open it automatically is to use the documentloaded event like this :

documentViewer.addEventListener('documentLoaded', async () => {
          instance.UI.openElements(['notesPanel', 'leftPanel']);
 });

The problem though , as mentionned in the thread I linked earlier, is that there is a closing and opening animation when loading a new document in the same instance (or when switching/opening tabs).

Another interesting information : this behaviour does not happen the first time when loading a document of webviewer was initialized without a document.
It only happens when you load a new document and a document was previously loaded.

Small demo of the behaviour :
D1woXOULd9