The first step to getting started with SDK is the installation and is available for download at NPM and GitHub. Among these, the easiest one is through npm. Execute the following command to perform the installation
npm install asposewordscloud
Also please be aware that SDK has the following dependencies which shall be resolved before performing any document processing.
@types/request (version 2.48.3+) lodash (version 4.17.15+) lodash.template (version 4.5.0+) request (version 2.88.0+) request-debug (version 0.2.0+)
After the installation, the next step is to create an account by visiting Aspose.Cloud dashboard. If you have GitHub or Google account, simply Sign Up. Otherwise, click on the Create a new Account button and provide the required information. Now login to the dashboard using credentials and expand the Applications section from the dashboard and scroll down towards the Client Credentials section to see Client ID and Client Secret details.
The cURL command approach
Aspose.Words Cloud APIs are developed on REST API architecture and therefore, they can also be accessed via cURL commands over the command line terminal. So in this section, we are going to discuss the steps on how to perform the DOC file to PDF format using the cURL command.
However, before accessing the APIs on the command line terminal, please note that we need to first generate a JWT access token based on Client ID and Client Secret details because the APIs are only accessed by authorized persons.
curl -v "https://api.aspose.cloud/connect/token" \ -X POST \ -d "grant_type=client_credentials&client_id=718e4235-8866-4ebe-bff4-f5a14a4b6466&client_secret=388e864b819d8b067a8b1cb625a2ea8e" \ -H "Content-Type: application/x-www-form-urlencoded" \ -H "Accept: application/json"
curl -X GET "https://api.aspose.cloud/v4.0/words/GetStyles.doc?format=pdf&outPath=Resultant.pdf" \ -H "accept: application/octet-stream" \ -H "Authorization: Bearer <JWT Token>"
DOC to PDF in Node.js
The following steps explain how to perform the conversion of the DOC file already available in cloud storage to PDF format and save the resultant document in the same cloud storage.
- First of all, create a variable holding Client ID and Client Secret details
- Secondly, initialize an instance of WordsApi while passing Client ID and Client Secret details as arguments
- Thrildy, create an object of GetDocumentWithFormatRequest class and define input DOC file name, resultant output format as PDF and name of final output file
- Finally, call getDocumentWithFormat(..) method of WordsApi class and pass GetDocumentWithFormatRequest object as an argument to initialize the conversion
This article has explained the concepts of MS Word document (DOC) conversion to PDF format using Aspose.Words Cloud SDK for Node.js. In simple few code lines, you get the capabilities to transform the Word document to a PDF that retains its formatting and fidelity on any platform. Please note that using the same approach, other formats such as DOCX, RTF, ODT can also be transformed. Furthermore, please note that all our Cloud SDKs are developed on the Opensource concept, so their complete source code is available for download over GitHub. For further details about product features, you may consider visiting the documentation module.
In case you encounter any issues while using the API or you have any related queries, please feel free to contact us through the Free Product support forum.
We also recommend visiting the following links to explore more features on