I am using node.js and the PUT /words/convert API to convert a docx to a pdf, I get the response body, but am trying to write the body to a pdf file on my computer. I cannot open the file because of corruption issues. Most likely something to do with the encoding
Thanks for your inquiry. Please check following Node.js code to save response body to PDF file. Hopefully it will help you to accomplish the task.
const { WordsApi, ConvertDocumentRequest } = require("asposewordscloud");
var fs = require('fs');
// Get App Key and App SID from https://dashboard.aspose.cloud/
wordsApi = new WordsApi("xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxx");
var request = new ConvertDocumentRequest({
format: "pdf",
document: fs.createReadStream("submission_V7.docx"),
});
var outputFile = "ConvertWordtoPDF.pdf";
wordsApi.convertDocument(request).then((result) => {
console.log(result.response.statusCode);
fs.writeFileSync(outputFile, result.body);
}).catch(function(err) {
// Deal with an error
console.log(err);
});
This is awesome. How do I use the same code to GetSections without uploading the document to storage using NodeJS as above?
Thank you!
I’m afraid currently there is no option available to get sections from request body. However, we have logged a feature request WORDSCLOUD-1324 for your requirement. We will update you as soon as it is implemented.
The issues you have found earlier (filed as WORDSCLOUD-1324) have been fixed in this update. This message was posted using Bugs notification tool by Ivanov_John