Skip to content

Instantly share code, notes, and snippets.

@aspose-cloud
Last active July 18, 2021 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-cloud/92436c51333704029cb320624e486151 to your computer and use it in GitHub Desktop.
Save aspose-cloud/92436c51333704029cb320624e486151 to your computer and use it in GitHub Desktop.
Convert DOC to PDF using Node.js
This Gist contains code snippets related to conversion of DOC file to PDF using Aspose.Words Cloud SDK for Node.js
const { WordsApi, GetDocumentWithFormatRequest } = require("asposewordscloud");
// Get clientId and clientSecret from https://dashboard.aspose.cloud/
const clientId = "718e4235-8866-4ebe-bff4-f5a14a4b6466";
const secret = "388e864b819d8b067a8b1cb625a2ea8e";
// create an instance of WordsApi
const wordsApi = new WordsApi(clientId, secret);
// Convert Word Document to PDF (the output will be saved in Cloud storage)
var fileName = "GetStyles.doc";
// start of try catch bloack
try {
var request = new GetDocumentWithFormatRequest ({
// name of input doc file
name : fileName,
// format of resultant file
format: "pdf",
// name of resultant file on CloudStorage
outPath : "Converted.pdf"
});
// initialize the document conversion operatoin
wordsApi.getDocumentWithFormat(request).then(() => {
// print success message on console
console.log("Successfully converted..");
})
}
catch (e) {
console.log("entering catch block");
console.log(e);
console.log("leaving catch block");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment