We're sorry AsposeCloud doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.cloud

How To Convert DOCX to PDF Purely Online in Node.js Using Aspose.Words REST API

Hi, the SDK examples that I have seen for converting a .docx to a .pdf format all seem to indicate that the file has to be uploaded in the request. Is there a way to convert a .docx that has already been uploaded, without first downloading it, using the cloud SDK?


You can convert DOCX to PDF purely online in Node.js using GetDocumentWithFormat API method of Aspose.Words REST API. Please check the sample code as follows for reference.

Code to Convert DOCX to PDF Online JavaScript

const { WordsApi, SaveAsRequest, SaveOptionsData } = require("asposewordscloud");
var fs = require('fs');

const convert = async () => {
// Initiate Aspose.Words REST API
// Please get your Client ID and Client Secret from https://dashboard.aspose.cloud/.
wordsApi = new WordsApi("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx", "xxxxxxxxxxxxxxxxxx");

const remoteFileName = "Sample.docx";
const resultFileName = "Sample.pdf";

// Convert DOCX to PDF
try {
const request = new SaveAsRequest({
                    name: remoteFileName,
                    saveOptionsData: new SaveOptionsData({
                        saveFormat: "pdf",
                        fileName: resultFileName,
                    //folder: remoteFolder,

const docToPDFResponse = await wordsApi.saveAs(request);
} catch (err) {
throw err;

.then(() => {
console.log("Word document converted successfully");
.catch((err) => {
console.log("Error occurred while converting the Word document:", err);
1 Like

Thanks @tilal.ahmad! That has sorted it.

1 Like