Memory Optimization Tips For WebViewer

Skip to first unread message

Chris Hampton

Aug 12, 2014, 10:03:51 AM8/12/14
Hello all,

We have some rather large documents that we run through the HTML5 WebViewer. Our problem is that with the default settings, the documents were printing very low res. I adjusted the window.utils.setCanvasMultiplier setting to 2, which made the page much better. However, the memory usage on a 150 pg document is now approximately 3.2GB, and crashes the browser.

Does anyone have any tips on how to decrease the memory usage, while maintaining some level of fidelity?

Thank you,

Chris Hampton
The Learning Institute

Kevin Kuo

Aug 12, 2014, 2:36:03 PM8/12/14
Hello Chris,

Unfortunately, the high memory usage is due to limitations of browsers and HTML5.

The major issues are:
-browsers do not print HTML5 canvases (must be rendered as images instead)
-browsers can only print HTML content already on the page (in DOM)

What this means for canvas-based web applications is that images need to be rendered from the canvas and inserted into the DOM (as dataURL) before users trigger printing. As you have noticed, the image data for all pages rendered at high resolution ends up taking up A LOT of memory. There is no good way to avoid this. 
This may not suit everyone's requirements, but HTML5 printing is best provided as a convenient way to print a small number of pages. (E.g. print an 10 page excerpt of the document).
For printing the entire document, it is best to offer a direct download to the XOD file (you can print it as an XPS file), or the original PDF file.

In Silverlight and Flash, the printing API provides callbacks for each page print. This means that only one page needs to be rendered at a time, so the memory usage can be kept relatively low.
Until such a feature is supported on browsers, HTML5 is not viable for printing many document pages in high resolution.

Kevin Kuo
Reply all
Reply to author
0 new messages