How to Convert Word DOC (97–03) Document to PDF in Node.JS

Cloudmersive
1 min readMar 19, 2020

--

Any time you have to deal with the legacy Microsoft Word DOC file format, everything just becomes a little bit more annoying. Generally speaking, it’s a lot nicer to simply remove the formatting from the equation by switching it over to something better, like PDF. Most Node.JS users will know that this is not an easy thing to set up, that is, until you see the method on display today. Stay tuned.

We begin with npm install, which we will use to set up our client.

npm install cloudmersive-convert-api-client --save

Following this, call our function as seen below.

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;// Configure API key authorization: Apikeyvar Apikey = defaultClient.authentications['Apikey'];Apikey.apiKey = 'YOUR API KEY';// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.apiKeyPrefix = 'Token';var apiInstance = new CloudmersiveConvertApiClient.ConvertDocumentApi();var inputFile = "/path/to/file"; // File | Input file to perform the operation on.var callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.convertDocumentDocToPdf(inputFile, callback);

OK, we are already done. Yup, super simple.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet