Some test text!

WebViewer Server Usage

Contents

Normal Usage
Caching and Performance
Server authentication
Extended API
PreloadURL
HealthCheck
GetPDF

linkNormal Usage

WebViewer Server is designed to work hand-in-hand with the WebViewer client in order to seamlessly optimize the viewing experience. Once the server is running, simply supply the pdftronServer argument to WebViewer upon startup:

options.pdftronServer = 'http://<docker_address>'
var myWebViewer = new PDFTron.WebViewer(options, viewerElement);

This will ensure an optimal client experience on any of your target platforms, optimizing the delivery method as required.

linkCaching and Performance

In order to handle requests as quickly as possible with minimal server load, WebViewer Server caches intermediate data opportunistically. For example, this might include includes caching parsed PDF content in memory for quick re-renders of the same doc, caching conversion results, fetched data, and render tiles, if used.

It will also batch requests together in order to minimize cpu-heavy operations like conversions -- if users Alice and Bob try to view the same Word document at the same time, then only one conversion to PDF will ever take place, and the will be broadcast to both users. For documents under high contention (as might happen when sharing a doc for review), the performance benefit can be tremendous.

In order for this caching and batching to work correctly, the server requires that incoming URLs map to documents in a one-to-one manner, including query parameters. If Alice and Bob access the same document but via different URLs, then the server will assume they are different documents and end up doing more work than is required. In order to ensure the cache is working as intended, it may be necessary to move unique URL query parameters (access tokens and time stamps, for example) into the request headers instead.

linkServer authentication

When a document URL is provided to WebViewer, that URL will now be fetched by the docker server instead of the browser. If authorization information needs to be provided to the server providing the document, this can be done using the customHeaders option when creating a document.

You can also provide the filename option to ensure that the server knows what type of file you are attempting to view (in case it is not clear from the URL).

options.customHeaders = {Cookie: "MYAUTHTOKEN=BF6CF50AB90C4025"};
options.filename = "Document.pdf";
var url = 'http://<documentserver>/FileDownload?param1=abcd&fetchid=dcba';
myWebViewer.loadDocument(url, options);

When the docker server makes a request to fetch http://<documentserver>/FileDownload?param1=abcd&fetchid=dcba, the http request will include the values in options.customHeaders.

linkExtended API

For most use cases no extra interaction with the server is required, beyond what is mentioned in the previous section. For special cases, these endpoints can be used to further optimize your application, or tailor it to your own particular use case

linkPreloadURL

Preload a document into WebViewer server prior to actually viewing it.

linkParams

linkurl

The URL of the document to be preloaded, should be a fully qualified absolute path

linkExample

For example, to pre-fetch http://domain/document.pdf, make a GET request to http://<docker_address>/blackbox/PreloadURL?url=http%3A%2F%2Fdomain%2Fdocument.pdf

linkReturns

Returns code 200 once the information has been received by the server. The response is asynchronous -- the return does not indicate that all preload work has been completed.

linkHealthCheck

Check whether your server is over capacity. WebViewer server has an internal threaded work queue which is used to perform all cpu-intensive actions, like rendering and document conversion. The HealthCheck endpoint monitors the wait time on this queue, and indicates when it becomes too high.

linkExample

For example, to check the state of your work queue, access http://domain/document.pdf, make a GET request to http://<docker_address>/blackbox/HealthCheck

linkReturns

  • response code 200 - the server is up, and capable of serving requests at interactive speeds.
  • response code 503 - the server is up, but over capacity.
  • any other response - outside the scope of this endpoint.

linkGetPDF

Convert a document to PDF format, and return the result. This functionality is not part of the default functionality of WebViewer server and must be licensed separately. Please talk to our sales team for more details.

linkParams

linkuri

The URI of the document to be converted, should be a fully qualified absolute path

linkfmt

(optional) The return format, if set to "data", will redirect to the actual pdf document, otherwise will return json data in the form [{"uri":"<location of the pdf>"}]

linkExample

To obtain http://domain/document.docx in PDF format, access , make a GET request to http://<docker_address>/blackbox/GetPDF?uri=http%3A%2F%2Fdomain%2Fdocument.docx&fmt=data

To instead obtain a json formated link to the conversion result, make a GET request to http://<docker_address>/blackbox/GetPDF?uri=http%3A%2F%2Fdomain%2Fdocument.docx

linkReturns

  • If fmt is set to "data", returns the converted PDF data.
  • Otherwise returns a url to the converted result, relative to http://<docker_address>/blackbox/. This result is in json: [{"uri":"<location of the pdf>"}]
  • In the case where this functionality has not been licensed, will return code 403 (forbidden).

Get the answers you need: Support

Contents

Normal Usage
Caching and Performance
Server authentication
Extended API
PreloadURL
HealthCheck
GetPDF