# Open image files from an array buffer using JavaScript

### PDF

[PDF](https://www.nutrient.io/guides/web/open-a-document/from-arraybuffer.md)

### MS Office

[MS Office](https://www.nutrient.io/guides/web/open-a-document/office-from-arraybuffer.md)

### Image

[Image](https://www.nutrient.io/guides/web/open-a-document/image-from-arraybuffer.md)

Nutrient Web SDK in standalone mode accepts different input data types for a document: either as the document URL string, or as an `ArrayBuffer` containing the document file. Set it in the `document` property of the [`NutrientViewer.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

// Standalone mode: loads document directly in the browser
NutrientViewer.load({
	container: "#pspdfkit",

	document: myDocumentArrayBuffer
}).then((instance) => {
		console.log("Document loaded successfully");
	}).catch((error) => {
		console.error("Failed to load document:", error);
	});

```

The `ArrayBuffer` can be constructed from a file in any of the [different supported input formats](https://www.nutrient.io/guides/web/viewer/office-documents.md).

It’s also possible to set the initial conditions of the viewer in the same configuration object by setting the [`initialViewState`](https://www.nutrient.io/api/web/NutrientViewer.Configuration.html#initialViewState) property. For example, if you want to open a document on page 8 with the thumbnails sidebar open, you can do it like this:

```js

// Standalone mode: loads document with custom initial view state
NutrientViewer.load({
	container: "#pspdfkit",

	document: myDocumentArrayBuffer,
	initialViewState: new NutrientViewer.ViewState({
		pageIndex: 8,
		sidebarMode: NutrientViewer.SidebarMode.THUMBNAILS
	})
}).then((instance) => {
		console.log("Document loaded on page 8 with thumbnails");
	}).catch((error) => {
		console.error("Failed to load document:", error);
	});

```

## 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)

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

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

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

* [`customFonts`](/api/web/NutrientViewer.Configuration.html#customFonts) (Standalone only)

* [`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)

* [`disableWebAssemblyStreaming`](/api/web/NutrientViewer.Configuration.html#disableWebAssemblyStreaming) (Standalone only)

* [`document`](/api/web/NutrientViewer.Configuration.html#document) (Standalone only)

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

* [`enableAutomaticLinkExtraction`](/api/web/NutrientViewer.Configuration.html#enableAutomaticLinkExtraction) (Standalone only)

* [`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)

* [`instantJSON`](/api/web/NutrientViewer.Configuration.html#instantJSON) (Standalone only)

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

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

* [`licenseKey`](/api/web/NutrientViewer.Configuration.html#licenseKey) (Standalone only)

* [`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)

* [`overrideMemoryLimit`](/api/web/NutrientViewer.Configuration.html#overrideMemoryLimit) (Standalone only)

* [`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)

* [`standaloneInstancesPoolSize`](/api/web/NutrientViewer.Configuration.html#standaloneInstancesPoolSize) (Standalone only)

* [`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)

* [`trustedCAsCallback`](/api/web/NutrientViewer.Configuration.html#trustedCAsCallback) (Standalone only)

* [`XFDF`](/api/web/NutrientViewer.Configuration.html#XFDF) (Standalone only)

* [`XFDFKeepCurrentAnnotations`](/api/web/NutrientViewer.Configuration.html#XFDFKeepCurrentAnnotations) (Standalone only)

**Example**:

```js

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

  document: documentUrl,
  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 Base64 in the browser using JavaScript](/guides/web/open-a-document/from-base64-data.md)
- [Open PDFs using DWS Viewer API](/guides/web/open-a-document/from-dws-viewer-api.md)
- [Open PDFs from an ArrayBuffer using JavaScript](/guides/web/open-a-document/from-arraybuffer.md)
- [Open local PDF files using JavaScript](/guides/web/open-a-document/from-local-storage.md)
- [Open and display PDFs from a Blob using JavaScript](/guides/web/open-a-document/from-blob.md)
- [Open and display PDF files from a remote URL using JavaScript](/guides/web/open-a-document/from-remote-url.md)
- [Open documents from Document Engine](/guides/web/open-a-document/from-document-engine.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 and display PDFs in the browser using JavaScript](/guides/web/open-a-document.md)
- [Open Base64 image files using JavaScript](/guides/web/open-a-document/image-from-base64-data.md)
- [Open image files from a Blob using JavaScript](/guides/web/open-a-document/image-from-blob.md)
- [Open MS Office files from a Blob using JavaScript](/guides/web/open-a-document/office-from-blob.md)
- [Open Base64 MS Office files using JavaScript](/guides/web/open-a-document/office-from-base64-data.md)
- [Open MS Office files from an ArrayBuffer using JavaScript](/guides/web/open-a-document/office-from-arraybuffer.md)
- [Open local MS Office files using JavaScript](/guides/web/open-a-document/office-from-local-storage.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)
- [Opening specific pages in PDFs using JavaScript](/guides/web/features/open-parameters.md)

