Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pdbradley/394f63d911cd82863876601813eb4b0a to your computer and use it in GitHub Desktop.
Save pdbradley/394f63d911cd82863876601813eb4b0a to your computer and use it in GitHub Desktop.
getFileAsync
function GetDocumentAsPdf(){
Office.context.document.getFileAsync(Office.FileType.Pdf, {sliceSize: 65536},
function (result) {
if (result.status == "succeeded") {
// If the getFileAsync call succeeded, then
// result.value will return a valid File Object.
var myFile = result.value;
var sliceCount = myFile.sliceCount;
var slicesReceived = 0, gotAllSlices = true, docdataSlices = [];
//app.showNotification("File size:" + myFile.size + " #Slices: " + sliceCount);
console.log("File size:" + myFile.size + " #Slices: " + sliceCount);
// Get the file slices.
getSliceAsync(myFile, 0, sliceCount, gotAllSlices, docdataSlices, slicesReceived);
}
else {
//app.showNotification("Error:", result.error.message);
console.log("Error:" + result.error.message);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment