How to close the viewer of free plugin

Hi I am using, “PDF.js Express Viewer”

Issue description:
I want to use the PDF.js Express Viewer in a modal of my webpage, but I want add a close button, which will hide the rended PDF.js Express Viewer. I tried with closeDocument() call but it just closes the page which is shown and not the viewer itself.

Is there a way to do it? I am also asking this because, my webpage, contains multiple pdf links in a single page, which upon clicking will show this modal with the related pdf.

So I want to cleanup the memory resources as well, if multiple pdfs or same pdf tried multiple times, can open without filling up browser memory, due to instantiation of PDF.js Express Viewer.

another solution can be if I can change the pdf url of the loaded PDF.js Express Viewer, programmatically.

Regards

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:

Share how you are using PDF.js Express in your organization you could win a $500 Amazon gift card. All participants will receive 6 months of PDF.js Express+ for free. Learn more here

Hi Gaurav,

What I would recommend in this situation is to remove the viewer from the DOM when closed and use the dispose() method to completely remove the instance.

https://pdfjs.express/api/WebViewerInstance.html#dispose__anchor

Then on click on one of the PDFs, reinstate the viewer with the PDF as the initial document.

Best Regards,
Zach Serviss
Web Development Support Engineer
PDFTron Systems, Inc.


Share how you are using PDF.js Express in your organization you could win a $500 Amazon gift card. All participants will receive 6 months of PDF.js Express+ for free. Learn more here