---
title: "Open PDF using DWS Viewer API | Nutrient Document Web Services"
canonical_url: "https://www.nutrient.io/guides/web/open-a-document/from-dws-viewer-api/"
md_url: "https://www.nutrient.io/guides/web/open-a-document/from-dws-viewer-api.md"
last_updated: "2026-05-15T15:26:54.098Z"
description: "Learn how to open PDF documents using the Nutrient Document Web Services (DWS) Viewer API. Integrate PDF viewing capabilities into your web applications."
---

# 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](https://www.nutrient.io/api/viewer-api/), pass the document’s session token for authentication in the [configuration](https://www.nutrient.io/api/web/NutrientViewer.Configuration.html) object passed to [`NutrientViewer.load()`](https://www.nutrient.io/api/web/NutrientViewer.html#.load):

```js

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

```

The [`<container>`](https://www.nutrient.io/api/web/NutrientViewer.Configuration.html#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>`](https://www.nutrient.io/api/viewer-api/documentation/client-authentication/generate-a-session-token/) placeholder should be replaced by the session token obtained from DWS Viewer API’s [dashboard](https://dashboard.nutrient.io/) or through its [API](https://www.nutrient.io/api/viewer-api/documentation/api/overview/). 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](https://www.nutrient.io/api/web/NutrientViewer.Configuration.html#password).

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

## Loading options

You can open files in any of the [supported file formats](https://www.nutrient.io/guides/web/about/file-type-support.md).

`NutrientViewer.load()` also accepts different configuration options:

* [`annotationTooltipCallback`](/api/web/NutrientViewer.Configuration.html#.annotationTooltipCallback)

* [`customRenderers`](/api/web/NutrientViewer.Configuration.html#.customRenderers)

* [`electronicSignatures`](/api/web/NutrientViewer.Configuration.html#.electronicSignatures)

* [`annotationPresets`](/api/web/NutrientViewer.Configuration.html#annotationPresets)

* [`session`](/api/web/NutrientViewer.Configuration.html#session) (DWS Viewer API only)

* [`autoSaveMode`](/api/web/NutrientViewer.Configuration.html#autoSaveMode)

* [`baseUrl`](/api/web/NutrientViewer.Configuration.html#baseUrl)

* [`container`](/api/web/NutrientViewer.Configuration.html#container)

* [`disableForms`](/api/web/NutrientViewer.Configuration.html#disableForms)

* [`disableHighQualityPrinting`](/api/web/NutrientViewer.Configuration.html#disableHighQualityPrinting)

* [`disableOpenParameters`](/api/web/NutrientViewer.Configuration.html#disableOpenParameters)

* [`disableTextSelection`](/api/web/NutrientViewer.Configuration.html#disableTextSelection)

* [`editableAnnotationTypes`](/api/web/NutrientViewer.Configuration.html#editableAnnotationTypes)

* [`enableServiceWorkerSupport`](/api/web/NutrientViewer.Configuration.html#enableServiceWorkerSupport)

* [`formFieldsNotSavingSignatures`](/api/web/NutrientViewer.Configuration.html#formFieldsNotSavingSignatures)

* [`headless`](/api/web/NutrientViewer.Configuration.html#headless)

* [`initialViewState`](/api/web/NutrientViewer.Configuration.html#initialViewState)

* [`instant`](/api/web/NutrientViewer.Configuration.html#instant) (Server and DWS Viewer API only)

* [`isEditableAnnotation`](/api/web/NutrientViewer.Configuration.html#isEditableAnnotation)

* [`isEditableComment`](/api/web/NutrientViewer.Configuration.html#isEditableComment)

* [`locale`](/api/web/NutrientViewer.Configuration.html#locale)

* [`maxDefaultZoomLevel`](/api/web/NutrientViewer.Configuration.html#maxDefaultZoomLevel)

* [`maxPasswordRetries`](/api/web/NutrientViewer.Configuration.html#maxPasswordRetries)

* [`minDefaultZoomLevel`](/api/web/NutrientViewer.Configuration.html#minDefaultZoomLevel)

* [`password`](/api/web/NutrientViewer.Configuration.html#password)

* [`populateInkSignatures`](/api/web/NutrientViewer.Configuration.html#populateInkSignatures)

* [`populateStoredSignatures`](/api/web/NutrientViewer.Configuration.html#populateStoredSignatures)

* [`preventTextCopy`](/api/web/NutrientViewer.Configuration.html#preventTextCopy)

* [`printMode`](/api/web/NutrientViewer.html#.PrintMode)

* [`renderPageCallback`](/api/web/NutrientViewer.Configuration.html#renderPageCallback)

* [`serverUrl`](/api/web/NutrientViewer.Configuration.html#serverUrl)

* [`stampAnnotationTemplates`](/api/web/NutrientViewer.Configuration.html#stampAnnotationTemplates)

* [`styleSheets`](/api/web/NutrientViewer.Configuration.html#styleSheets)

* [`theme`](/api/web/NutrientViewer.Configuration.html#theme)

* [`toolbarItems`](/api/web/NutrientViewer.Configuration.html#toolbarItems)

* [`toolbarPlacement`](/api/web/NutrientViewer.Configuration.html#toolbarPlacement)

**Example**:

```js

NutrientViewer.load({
  container: "#pspdfkit",

  session: "<session_token>",
  instant: true,
  toolbarItems: NutrientViewer.defaultToolbarItems.filter(item => item.type!== "print"),
  initialViewState: new NutrientViewer.ViewState({
    sidebarMode: NutrientViewer.SidebarMode.THUMBNAILS
  })
}).then((instance) => {
    console.log("Document loaded successfully");
  }).catch((error) => {
    console.error("Failed to load document:", error);
  });

```
---

## Related pages

- [Open PDFs from an ArrayBuffer using JavaScript](/guides/web/open-a-document/from-arraybuffer.md)
- [Open PDFs from Base64 in the browser using JavaScript](/guides/web/open-a-document/from-base64-data.md)
- [Open and display PDFs from a Blob using JavaScript](/guides/web/open-a-document/from-blob.md)
- [Open documents from Document Engine](/guides/web/open-a-document/from-document-engine.md)
- [Open image files from an array buffer using JavaScript](/guides/web/open-a-document/image-from-arraybuffer.md)
- [Open Base64 image files using JavaScript](/guides/web/open-a-document/image-from-base64-data.md)
- [Open local image files using JavaScript](/guides/web/open-a-document/image-from-local-storage.md)
- [Open image files from a URL using JavaScript](/guides/web/open-a-document/image-from-remote-url.md)
- [Open local PDF files using JavaScript](/guides/web/open-a-document/from-local-storage.md)
- [Open and display PDFs in the browser using JavaScript](/guides/web/open-a-document.md)
- [Open and display PDF files from a remote URL using JavaScript](/guides/web/open-a-document/from-remote-url.md)
- [Open MS Office files from an ArrayBuffer using JavaScript](/guides/web/open-a-document/office-from-arraybuffer.md)
- [Open Base64 MS Office files using JavaScript](/guides/web/open-a-document/office-from-base64-data.md)
- [Open image files from a Blob using JavaScript](/guides/web/open-a-document/image-from-blob.md)
- [Open local MS Office files using JavaScript](/guides/web/open-a-document/office-from-local-storage.md)
- [Open MS Office files from a Blob using JavaScript](/guides/web/open-a-document/office-from-blob.md)
- [Opening specific pages in PDFs using JavaScript](/guides/web/features/open-parameters.md)
- [Temporary storage for PDF downloads](/guides/web/open-a-document/temp-storage.md)
- [Open MS Office files from a URL using JavaScript](/guides/web/open-a-document/office-from-remote-url.md)

