I am using Aspose to store a PDF, and that works well. I use S3 as my storage so if I download the file directly from S3 the file works fine. However, I cannot get a well formed PDF document when I’m using the node words api. What I’m doing is pretty simple, but the contents I get is never well formed and the file will not open with Preview on MacOS 12.5.1
Please double check that you are using the latest version of the Aspose.Words Cloud SDK for Node.js. I have tested the scenario as follows and unable to notice any issues.
const { WordsApi, DownloadFileRequest } = require("asposewordscloud");
var fs = require('fs');
const download = async () => {
// Get Customer ID and Customer Key from https://dashboard.aspose.cloud/
wordsApi = new WordsApi("XXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX", "XXXXXXXXXXXXXXXX");
try {
const request = new DownloadFileRequest({
path: "02_pages.pdf",
storage: "MyDB_Storage"
});
const outputFile = "C:/Temp/Output.pdf";
const result = await wordsApi.downloadFile(request);
fs.writeFileSync(outputFile, result.body);
} catch (err) {
throw err;
}
}
download()
.then(() => {
console.log("document downloaded.... successfully");
})
.catch((err) => {
console.log("Error occurred while downloading the Word document:", err);
})