In This Topic
Reference Guides / JavaScript API / Actions / Document / LoadFromByteArray

LoadFromByteArray

In This Topic
 LoadFromByteArray

This asynchronous function allows you to load a document into the DocuVieware™ viewer from a byte array.

LoadFromByteArray: function (docuViewareID, fileData, fileType, fileName, success, error)

Parameters

docuViewareID
The identifier for the DocuVieware™ instance you want to load the document in.
fileData
The byte array that contains the document content data.
fileType
A string that contains the document file MIME type, for instance "application/pdf" for a PDF document.
fileName
A string that contains the document file name.
success
A function that will be executed upon success.
error
A function that will be executed upon error.

Example of usage

This code loads a document from an HTML file input as a byte array in a DocuVieware™ instance.

var file = document.getElementById("input").files[0];
var reader = new FileReader();
reader.onload = function () {
   var arrayBuffer = this.result;
   DocuViewareAPI.LoadFromByteArray("DocuVieware1", arrayBuffer, file.type, file.name,
      function () { console.log("success"); },
      function () { console.log("error"); }
   );
}
reader.readAsArrayBuffer(file);

Return Value

1 if error, 0 if success.