Closing HTML5 Webviewer

333 views
Skip to first unread message
Message has been deleted

Pierre-Yves Gicquel

unread,
Mar 21, 2014, 6:51:08 AM3/21/14
to pdfnet-w...@googlegroups.com
Hello

We are experiencing problem to close the html5 WebViewer.

It seems that the function provided in the JS API does not actually free memory. For instance if a document is loaded like this :
var myWebViewer = new PDFTron.WebViewer({
type : "html5",
initialDoc : "test.xod",
showToolbarControl : false,
enableAnnotations : true
}, myWebViewerContainer);

How does one close this doc and free memory? We tried :
myWebViewer.instance.docViewer.CloseDocument()
myWebViewer.instance.docViewer.RemoveContent()
myWebViewer.instance.docViewer.Dispose()

Nothing seems to actually clean memory, which leads to very bad performance issue on the website after closing the webviewer.

Could you give me a working example on how to cleanly close the webviewer?
Thanks in advance

Matt Parizeau

unread,
May 25, 2017, 6:02:24 PM5/25/17
to pdfnet-w...@googlegroups.com
Hi,

closeDocument will call removeContent and dispose internally so you don't need to worry about that.  If you're not using WebViewer anymore on the page then you could probably just remove the viewer element from the DOM.

Try code like the following:
myWebViewer.getInstance().closeDocument();
myWebViewer = null;

var iframeWindow = $('iframe')[0].contentWindow;
iframeWindow.$(iframeWindow.document).off();
$(myWebViewerContainer).remove();

Matt Parizeau
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages