DOCX to PDF Conversion with Aspose.Words Cloud SDK for Node.js PostDocumentSaveAsRequest error

Hi,

I am using the aspose.words sdk for node.js. I am getting a ‘TypeError: PostDocumentSaveAsRequest is not a constructor’ from the following:

var request = new PostDocumentSaveAsRequest({
name: response.fileName,
saveOptionsData: new SaveOptionsData(
{
saveFormat: “pdf”,
fileName: response.fileName.replace(’.docx’, ‘.pdf’)
})
});

Thank you

@adesai6

Thanks for your inquiry. Please note we have recently released an improved API version 4. We have released updated Node.js SDK for V4 version on NPM as well. There are a lot of breaking changes. PostDocumentSaveAsReqest changed to SaveAsRequest. Please find sample code for reference. However, if you face any issue please feel free to contact us for any assistance. Please note V1.1 will remain working with previous SDKs.

const request = new SaveAsRequest({
                        saveOptionsData: new SaveOptionsData({
                            saveFormat: "pdf",
                            fileName: "Test.pdf",
                        }),

                    });
                    request.name = "Test.docx";
                    request.folder = "Temp";

wordsApi.saveAs(request).then((result) => {    
    console.log(result.body);    
}).catch(function(err) {
    // Deal with an error
    console.log(err);
});