# How to close the viewer of free plugin

**URL:** <https://pdfjs.community/t/how-to-close-the-viewer-of-free-plugin/2087>\
**Category:** Technical Support\
**Created:** [October 2, 2022, 8:48pm UTC](https://pdfjs.community/t/how-to-close-the-viewer-of-free-plugin/2087 "2022-10-02T20:48:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaurav.arora0403](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/gaurav.arora0403/32/1036_2.png) [@gaurav.arora0403](https://pdfjs.community/u/gaurav.arora0403)\
**Post date:** [October 2, 2022, 8:48pm UTC](https://pdfjs.community/t/how-to-close-the-viewer-of-free-plugin/2087/1 "2022-10-02T20:48:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/ffbcd25c7d423db8d5acd5db201c272f4db306dd.png) [@system](https://pdfjs.community/u/system)\
**Post date:** [October 2, 2022, 8:48pm UTC](https://pdfjs.community/t/how-to-close-the-viewer-of-free-plugin/2087/3 "2022-10-02T20:48:07Z")

</div>

**Hello, I’m Ron, an automated tech support bot 🤖**

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

Guides:
- [Manually Download & integrate PDF.js Express Plus - Integrate into your application](https://pdfjs.express/documentation/get-started/manually#integrate-into-your-application)
- [Set up real-time collaboration](https://pdfjs.express/documentation/collaboration/setup)
- [Best practices for PDF.js Express - Load documents with loadDocument](https://pdfjs.express/documentation/learn-more/best-practices#load-documents-with-loaddocument)

APIs:
- [PDF.js Express Utilities](https://pdfjs.express/api/utils/index.html#__anchor)
- [ExpressUtils(optionsopt) - # async set() → {Promise.}](https://pdfjs.express/api/utils/ExpressUtils.html#set__anchor)
- [Core - onDateSelected(date)](https://pdfjs.express/api/Core.html#.onDateSelected__anchor)

Forums:
- [Access to PDF.js viewer when your servers are unavailable](https://pdfjs.community/t/access-to-pdf-js-viewer-when-your-servers-are-unavailable/1260/1)
- [Hyperlinks not being detected in pdf.js viewer](https://pdfjs.community/t/hyperlinks-not-being-detected-in-pdf-js-viewer/1925/1)
- [What version of PDF.js Express we should use](https://pdfjs.community/t/what-version-of-pdf-js-express-we-should-use/1542/1)

  
  

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](https://utm.guru/ueQNw)

---

<div class="post-metadata">

**Author:** ![zserviss](https://avatars.discourse-cdn.com/v4/letter/z/a9a28c/32.png) [@zserviss](https://pdfjs.community/u/zserviss)\
**Post date:** [October 3, 2022, 5:46pm UTC](https://pdfjs.community/t/how-to-close-the-viewer-of-free-plugin/2087/4 "2022-10-03T17:46:24Z")

</div>

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](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](https://utm.guru/ueQNw)
