Open PDFs using DWS Viewer API

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 NutrientViewer.load():

NutrientViewer.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(opens in a new tab) 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.

NutrientViewer.load() also accepts different configuration options:

  • instant (Server and DWS Viewer API only)

Example:

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