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 const arr = new Uint8Array(arrayBuffer);
7 const blob = new Blob([arr], { type: 'application/pdf' });
8 instance.UI.loadDocument(blob, { filename: 'myfile.pdf' });
9
10 const { documentViewer } = instance.Core;
11 documentViewer.addEventListener('documentLoaded', () => {
12 // perform document operations
13 });
14 });

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