> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/web/open-save-document/open/arraybuffer.md).

# Open a document from ArrayBuffer

Efficiently open a document in WebViewer from ArrayBuffer using the blob format. The Apryse Web SDK streamlines secure, serverless document processing with robust support for JavaScript and TypeScript

## Opening a document from ArrayBuffer

If your document is already in [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/) format you can convert the ArrayBuffer object to a [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob/) and then pass resulting Blob directly to loadDocument function.

{% tabs %}
{% tab title="JavaScript (SDK v8.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer(...)
  .then(instance => {

    // `arrayBuffer` is your buffer data which can come
    // from sources such as a server or the filesystem
    instance.UI.loadDocument(arrayBuffer, {
    // You need to specify either the file name of extension so
    // that WebViewer knows how to interpret the data
    filename: 'myfile.docx'
    
    // You can also change the InitialMode with WebViewer 11
    // initialMode: WebViewer.Modes.DOCX_EDITOR,
    });

    const { documentViewer } = instance.Core;
    documentViewer.addEventListener('documentLoaded', () => {
      // perform document operations
    });
  });
```

{% endcode %}

[UI.loadDocument](https://sdk.apryse.com/api/web/UI.html#loadDocument__anchor)
{% endtab %}

{% tab title="JavaScript (SDK v6.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer(...)
  .then(instance => {

    // `arrayBuffer` is your buffer data which can come
    // from sources such as a server or the filesystem
    const arr = new Uint8Array(arrayBuffer);
    const blob = new Blob([arr], { type: 'application/pdf' });
    instance.UI.loadDocument(blob, { filename: 'myfile.pdf' });

    const { docViewer } = instance.Core;
    docViewer.on('documentLoaded', () => {
      // perform document operations
    });
  });
```

{% endcode %}

[WebViewerInstance.loadDocument](https://sdk.apryse.com/api/web/UI.html#loadDocument__anchor)
{% endtab %}
{% endtabs %}

{% hint style="warning" %}
If you are loading from an array buffer, please ensure the [extension](/web/open-save-document/open.md#the-extension-option) or [filename](/web/open-save-document/open.md#the-filename-option) options are set while loading.
{% endhint %}

## Loading Options

WebViewer provides various options to load a document. Whether you are loading a document through the `initialDoc` option in the constructor or calling `loadDocument` after mounting, you can always provide [options to load your document](/web/open-save-document/open.md#loading-options).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.apryse.com/web/open-save-document/open/arraybuffer.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
