Using the streaming option with WebViewer

In this document
The streaming option is only applicable when loading XOD files. If you're loading PDF or Office files directly then you can skip this guide.

By default WebViewer loads XOD documents by only downloading the parts of the file that are required to display the currently visible pages. This approach decreases load times and memory usage because the entire file doesn't have to be downloaded up front.

As long you pre-convert XOD files and host them on a server that supports byte range request headers, which most do, then you get this optimization by default.

The exact checklist is the following:

  1. Pre-Convert files to XOD (instead of converting during viewing).
  2. Host XOD files on server that supports byte range request headers.
  3. Don't set the streaming mode in your WebViewer constructor (default is false, which is what you normally want).

So what is streaming: true good for?

The streaming option should be set to true only if the conversion of the XOD file is being streamed/done on the fly. WebViewer will be able to load the file in chunks as the conversion is streamed, however it will have to take in the entire file at the beginning.

For medium to large files (more noticeable on mobile devices) this can cause the viewer to appear sluggish when loading the document because it is processing and storing everything in memory at the same time!

Setting the streaming option to true may be useful if there are small, dynamically generated files uploaded to or created on your server. Since the files are small the download time and memory usage won't be very large.

This also means that you won't have to store many documents on your server that are only viewed once. The PDFNet SDK download includes a WebViewerStreaming sample that can help you get started with this.