Some test text!

Constructor options

In this document
chevron_rightannotationAdmin
chevron_rightannotationUser
chevron_rightazureWorkaround
chevron_rightconfig
chevron_rightcustom
chevron_rightdocumentId
chevron_rightdocumentType
chevron_rightenableAnnotations
chevron_rightenableReadOnlyMode
chevron_rightinitialDoc
chevron_rightpath
chevron_rightserverUrl
chevron_rightui

Instantiating WebViewer can be as simple as using the initialDoc option but there are many other options available to you that can be useful. This guide describes a few of the more common options. The full list of options can be found in the WebViewer API documentation.

linkannotationAdmin

An option to grant admin permission to the user. Seeting this option to true means the user can edit any annotation regardless of whether they created it. See permissions on annotations for details.

linkannotationUser

An option to name of the current user. The current user will only be able to edit annotations that they have created. See permissions on annotations for details.

linkazureWorkaround

If you store your documents with Microsoft Azure then you should enable this option. Azure doesn't properly implement all parts of the range request specification so this workaround adds an extra HTTP round trip when initially loading the document.

If you have a mix of documents in different locations for some reason this option won't cause any problems, it will just add the extra HTTP request.

linkconfig

The config option allows you to specify a JavaScript file that will be executed inside the WebViewer iframe.

It's the easiest way to keep your WebViewer customizations decoupled from the default viewer code.

linkcustom

Pass custom data that can be accessed from inside your config file. This option should be a string, so you can pass non-strings by stringifying them (for example JSON.stringify).

linkdocumentId

A unique identifier for the document that is used for saving and loading annotations. The id is passed as a query parameter to your server so that it can identify which document to return the annotations for.

linkdocumentType

By default WebViewer will look at the extension of the file that initialDoc is sent to but sometimes document URLs on your server won't have a file extension. If this is the case then you'll need to explicitly pass xod or pdf depending on which file you are loading.

linkenableAnnotations

An option to enable annotations. Default value is true. Setting this option to false disables annotation feature and hides annotations in the document.

linkenableReadOnlyMode

An option to enable readonly. Setting this option to true forces the document into a readonly state so that no one can create or edit annotations, regardless of who created them. See permissions on annotations for details.

linkinitialDoc

An option to set an initial document.

linkpath

This is the path to the folder that contains the html5 folder and the WebViewer.min.js file relative to your HTML file. For example if your file structure looks like this:

index.html
lib
  html5
  WebViewer.min.js

Then you'll set the option as follows:

var myWebViewer = new PDFTron.WebViewer({
  path: 'lib',
  initialDoc: 'mydoc.pdf'
}, viewerElement);

If you file structure looks like this:

pages
  index.html
libs
  WebViewer
    html5
    WebViewer.min.js

Then you'll set the option as path: '../libs/WebViewer'.

linkserverUrl

A URL on your server that handles the saving and loading of annotations. WebViewer will make calls to this URL when it wants to load or save annotations. You can handle this saving and loading manually but the serverUrl is the simplest option.

See the annotation loading guide for more information.

linkui

An option to choose what UI to render. The default is set to default, but you can set it to legacy to use the legacy viewer.