getInstance( [element])

Gets an already existing instance of WebViewer. If only one instance of WebViewer exists on the page, then 'element' is not required, and the function will return the instance of WebViewer. If more than one instance of WebViewer exists, you must pass in the DOM element containing the instance of WebViewer you want to retrieve. This function can be imported directly as a module as well.
Name Type Argument Description
element HTMLElement <optional>
The DOM element containing the instance of WebViewer you want to retrieve
Returns an instance of WebViewer. Returns null if no instances are available.
import { getInstance } from '@pdftron/webviewer'

// After WebViewer has already been constructed
const instance = getInstance();

WebViewer(options, viewerElement)

A function that creates an instance of WebViewer, and embeds it on the HTML page
Name Type Description
options WebViewerOptions
viewerElement HTMLElement
A promise resolved with WebViewer instance.
      licenseKey: 'Insert commercial license key here after purchase'
    }, document.getElementById('viewer'))
      .then(function(instance) {
        const documentViewer = instance.Core.documentViewer;
        const annotationManager = instance.Core.annotationManager;
        // call methods from instance, documentViewer and annotationManager as needed

        // you can also access major namespaces from the instances as follows:
        // const Tools = instance.Core.Tools;
        // const Annotations = instance.Core.Annotations;

Type Definitions


  • object
Name Type Description
obj string the unique identifier of the layer. This is not defined if the layer is a label
name string the name of the layer. It does not have not be unique
locked boolean boolean to denote if the layer is locked for viewing. This state cannot be toggled by the user through the user interface
visible boolean boolean to denote if the layer is visible
children Array.<LayerContext> the layer's children (if any). This is not defined if the layer is a label.


the point in viewer coordinates
  • Object
Name Type Description
Start Core.Math.Point the start point
End Core.Math.Point the end point


Callback function for when a date is selected
Name Type Description
date string selected Date


  • object
Name Type Description
type string Required type of 'customPageOperation'
header string Header to be displayed in the UI for this section
dataElement string Unique dataElement
operations Array.<PageOperation> the operations that will be available under this section


  • object
Name Type Description
title string Title to be displayed for the operation
img string path to imge to be used as an icon for the operation
onClick function onClick handler, which takes as a parameter an array of selected page numbers
dataElement string Unique dataElement for this operation


  • Object
Name Type Argument Default Description
path string Path to the WebViewer lib folder
annotationUser string <optional>
Guest Name of the user for annotations
config string <optional>
URL path to a custom JavaScript for customizations
custom string <optional>
A serialized data object that will be passed into the iframe. The data can be accessed in the config file after deserializing.
css string <optional>
URL path to a custom CSS file for customizations
disabledElements Array.<string> <optional>
List of data-elements to be disabled in UI
accessibleMode boolean <optional>
false Enable accessibility features. E.g tab page selection and page text in the DOM
enableAnnotations boolean <optional>
true Enable annotations feature
enableAzureWorkaround boolean <optional>
false Enable workaround of the issue in Azure related to range requests
enableFilePicker boolean <optional>
false Enable file picker feature
enableMeasurement boolean <optional>
false Enable measurement tools
enableRedaction boolean <optional>
false Enable redaction tool
extension string <optional>
Extension of the document to be loaded
filename string <optional>
The name of the file that will be used when downloading the document. The extension in the filename will be used as the document type to be loaded (e.g. myfile.docx will treat the file as docx) if no extension option is passed.
forceClientSideInit boolean <optional>
false If set to true then when loading a document using WebViewer Server the document will always switch to client only rendering allowing page manipulation and the full API to be used.
loadAsPDF boolean <optional>
false If set to true then when loading an office document, it'll be converted to a PDF file. This allow page manipulation and other features to be used
fullAPI boolean <optional>
false Enable PDFNet.js library functions
initialDoc string <optional>
URL path to a document to load on startup
isAdminUser boolean <optional>
false Set user permission to admin
isReadOnly boolean <optional>
false Set user permission to read-only
licenseKey string <optional>
License key for viewing documents. If not set then WebViewer will be in demo mode.
mobileRedirect boolean <optional>
false Whether the viewer should redirect to a new window or not when loaded on a mobile device
preloadWorker string <optional>
Type of workers to be preloaded. Accepts `pdf`|`office`|`legacyOffice`|`all`. You can also include multiple types comma separated e.g. `pdf,office`
backendType string <optional>
A string representing the "backend type" for rendering PDF documents. Pass "ems" to force the use of the ASM.js/WebAssembly worker and "wasm-threads" for threaded WebAssembly
useDownloader boolean <optional>
A boolean indicating whether Downloader should be used on urls (PDF only).
workerTransportPromise object <optional>
Name Type Argument Description
pdf function <optional>
Promise that resolves to a PDF worker
office function <optional>
Promise that resolves to an office worker
webviewerServerURL string <optional>
The URL path to the hosted WebViewer Server
singleServerMode boolean <optional>
false Set server to ignore health failures. For usage with setups using a single server
disableLogs boolean <optional>
false Disables console logs coming from WebViewer, including the version and build numbers
enableViewStateAnnotations boolean <optional>
false Enables view state annotations (double clicking a sticky annotation will reset the viewer to the state it was in when the annotation was created)
uiPath string <optional>
Path to UI folder to use a different UI or customized UI. Default is'./ui/index.html'.
notesInLeftPanel boolean <optional>
false If true then it moves the notes panel into a tab inside the left panel
selectAnnotationOnCreation boolean <optional>
false If true then newly added annotations will be selected automatically
highContrastMode boolean <optional>
false If true then the UI will use high contrast colors to help with accessibility.
documentXFDFRetriever Core.DocumentViewer.DocumentXFDFRetriever <optional>
null The XFDF retriever that will be called when a document is being loaded. The retriever should return a Promise which should resolve to the XFDF string that is going to merged into the document
streaming boolean <optional>
A boolean indicating whether to use http or streaming PartRetriever, it is recommended to keep streaming false for better performance.