Open a document from ArrayBuffer

Opening a document from ArrayBuffer

If your document is already in ArrayBuffer format you can convert the ArrayBuffer object to a Blob and then pass resulting Blob directly to loadDocument function.

1WebViewer(...)
2 .then(instance => {
3
4 // `arrayBuffer` is your buffer data which can come
5 // from sources such as a server or the filesystem
6 instance.UI.loadDocument(arrayBuffer, {
7 // You need to specify either the file name of extension so
8 // that WebViewer knows how to interpret the data
9 filename: 'myfile.docx'
10
11 // You can also change the InitialMode with WebViewer 11
12 // initialMode: WebViewer.Modes.DOCX_EDITOR,
13 });
14
15 const { documentViewer } = instance.Core;
16 documentViewer.addEventListener('documentLoaded', () => {
17 // perform document operations
18 });
19 });

If you are loading from an array buffer, please ensure the extension or filename options are set while loading.

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.

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales