Unload single page?

91 views
Skip to first unread message

Thomas Allen

unread,
Jul 30, 2014, 2:21:57 PM7/30/14
to pdfnet-w...@googlegroups.com
We have implemented our own WebViewer using the CoreControls.Document API, but I can't find a way to unload a specific page/canvas.

Unfortunately, the library is caching any images in a javascript variable and does not release them until a new document is loaded. For scanned documents with many pages, this makes the browser unusable after scrolling through about 20-30 pages (browser memory exceeds 1 gig in a short amount of time).

I am clearing out our DOM / canvases, but the CoreConrols library is still caching these images, regardless of whether I set SetCachingLevel to 0. The variable is "ci" in the obfuscated code.

Is there a way I can clear a single page after it has loaded? If not, can this method be added to the CoreControls.Document API?

Matt Parizeau

unread,
Jul 31, 2014, 2:05:08 PM7/31/14
to pdfnet-w...@googlegroups.com
Currently there isn't a function to unload the resources for a single page. For your case it would probably be simplest to just clear out window.ci after your page is loaded (assuming you're not loading multiple pages concurrently). So just window.ci = {}.

This makes sense to have so we'll look into adding a new function for this. For your case you would want this function to clean up the resources of a page loaded using Document.LoadCanvasAsync?

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Thomas Allen

unread,
Jul 31, 2014, 5:36:38 PM7/31/14
to pdfnet-w...@googlegroups.com
Clearing out window.ci doesn't seem to work. While we do load multiple pages concurrently (which makes this strategy problematic), even if we wait for all pages to load before clearing out window.ci, then when we attempt to load a previously-loaded page again, it won't load. I assume there are other variables that think the original page has already loaded, so it doesn't load it again.

For example, we load page 1-5 when the document is loaded. If I clear window.ci after that, then scroll to page 6, clear out the DOM and associated canvases for page 1, and then scroll back to page 1 (which calls LoadCanvasAsync), the canvas we get back is blank.

Are there other resources that need to be cleaned up? Is that possible without having access to your unobfuscated code?

And to answer your question, yes we are calling Document.LoadCanvasAsync and then in our callback function we are adding the canvas objects to the DOM. We just want to be able to clean up the page-specific resources when those pages go outside of a given scroll window.

Matt Parizeau

unread,
Aug 1, 2014, 1:39:47 PM8/1/14
to pdfnet-w...@googlegroups.com
Hmm, I had tried without loading pages concurrently and it had seemed to work. Regardless that was really just a temporary hack to workaround the issue. In the next version we'll be including a new function to unload the resources associated with a LoadCanvasAsync call and we're hoping to release it within the next couple weeks.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Thomas Allen

unread,
Aug 4, 2014, 2:23:34 PM8/4/14
to pdfnet-w...@googlegroups.com
Thanks- I will be looking for a new version and will let you know how it works once we test it out.
Reply all
Reply to author
Forward
0 new messages