Open PDFs using DWS Viewer API

Information

Nutrient Web SDK version 1.2 or newer is required to interface with DWS Viewer API. Upgrade first before following this guide.

To load a document from DWS Viewer API, pass the document’s session token for authentication in the configuration object passed to PSPDFKit.load():

PSPDFKit.load({
  container: "<container>",
  session: "<session_token>"
});

The <container> placeholder in the code above should be replaced by a CSS selector or a DOM element where Nutrient Web SDK will be mounted.

The <session_token> placeholder should be replaced by the session token obtained from DWS Viewer API’s dashboard or through its API. Session tokens are used for authenticating Nutrient Web SDK clients when connecting to DWS Viewer API.

Accessing a password-protected document

To load password-protected PDFs, you can provide the password option in the configuration.

Alternatively, you’ll be asked to enter the password through a password prompt.

Password prompt shown for the password-protected document.

Loading options

You can open files in any of the supported file formats.

PSPDFKit.load() also accepts different configuration options:

Example:

PSPDFKit.load({
  container,
  session: "<session_token>",
  instant: true,
  toolbarItems: PSPDFKit.defaultToolbarItems.filter(item => item.type !== "print"),
  initialViewState: new PSPDFKit.ViewState({
    sidebarMode: PSPDFKit.SidebarMode.THUMBNAILS
  })
})