If you're trying to load a PDF document and the URL doesn't have an extension you might get this error. You can let WebViewer know that it should treat this file as a PDF by passing the option documentType: 'pdf' to the PDFTron.WebViewer constructor.

If your application allows it you should preload WebViewer so that when your users want to view a document, WebViewer's JavaScript, HTML and CSS will already be loaded.

It's important that your server supports HTTP range requests properly so that WebViewer can load documents incrementally instead of having to download the entire file up front.

If you're serving your files statically from your server usually range requests will just work, however if you have your own endpoint for the file there are libraries that can handle range requests for you, or you could implement support yourself.

If you are making a request to a document that is on a different origin than your web app then you may see this error even when the document loads successfully. WebViewer attempts to read the Content-Range response header as part of determining if the document is linearized, so failure to read it means that it won't be able to enable optimizations for linearized files.

You can expose this header to cross origin requests by including the Access-Control-Expose-Headers header in your response: Access-Control-Expose-Headers: Content-Range.

If you see a 404 for files on your server but you're very sure that the files are there then you may need to set MIME types for certain file extensions used by WebViewer. With IIS you will generally need to do this and the process may vary slightly depending on your server.

Regardless of the documents that you're loading you'll need to add the MIME type for json files (application/json) so that the UI text is loaded. If you see buttons or labels in the UI with names like controlbar.fullScreen then that means the json file wasn't loaded successfully.

linkFailed to load document. The document is either corrupt or not a valid PDF document.

If you are trying to load a PDF file then you should try opening the document in another PDF viewer to confirm that it loads. If it doesn't load in any other viewers then your PDF file may be corrupt or invalid.

This error may also occur if you're loading a XOD document but WebViewer thinks you want to load a PDF. By default WebViewer will look at the extension of the path that you pass to initial doc and if it ends in .pdf it will treat the document as a PDF. You may see an error that looks like:

If your file path looks something like myserver.com/conversion-to-xod.asp?doc=GettingStarted.pdf then WebViewer will treat it as a PDF file because of the extension at the end. To override this you can pass the option documentType: 'xod' to the WebViewer constructor. This will force WebViewer to treat the document as a XOD file.

This error usually means that your server does not support HTTP range requests properly. Instead of downloading a small part of the file it is downloading the entire file.

If you're serving your files statically from your server usually range requests will just work, however if you have your own endpoint for the file there are libraries that can handle range requests for you, or you could implement it support yourself.

As a last resort you can set the streaming option in the WebViewer constructor to true. This is intended for streaming of the XOD conversion but can be used as a workaround for servers that don't support range requests at the cost of reduced performance and increased memory usage. See this guide for more information.

If the documents that you want to load are on a different domain than your WebViewer files you'll need to enable CORS on your document server. This site contains more information about how to enable CORS on your server.

If you're using Google Cloud Storage you can refer to Google's documentation on how to set up CORS on a bucket https://cloud.google.com/storage/docs/cross-origin.
They describe a few different ways you can upload the CORS configuration to Cloud Storage.