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 a free 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 obtain your personalized Client Credentials. We are going to use these details in the following sections.
DOC to PDF in Node.js
The following steps explain the details on how to perform the conversion of DOC file already available in cloud storage to PDF format. After the conversion, the resultant file is saved in 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
- Thirdly, create an object of GetDocumentWithFormatRequest class and define the input DOC file name, resultant output format as PDF, and name of the final output file
- Finally, call the getDocumentWithFormat(..) method of WordsApi class and pass the GetDocumentWithFormatRequest object as an argument to initialize the conversion
Word to PDF using cURL Commands
As Aspose.Words Cloud API is developed on REST architecture, so we can access them via cURL commands over the command line terminal. Now before accessing the APIs on the command line terminal, we need to first generate a JWT access token based on Client ID and Client Secret details. Please execute the following command to generate the JWT token.
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"
Once the JWT token has been generated, access GetDocumentWithFormat API to perform DOC to PDF conversion.
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>"
This article has explained the details of developing a Word to PDF converter using Node.js. With few code lines, we can transform DOC to PDF while retaining its formatting and fidelity. Please note that using the same approach, other formats such as DOCX, RTF, and ODT can also be converted to PDF. Nonetheless, all our SDKs are developed under the Opensource concept, so their complete source code is available for download over GitHub.
You may learn about other product features by 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