How to Convert Word DOC Files to DOCX in Node.JS
As file formats are updated and changed to meet the needs of new software, older documents may become more difficult to use because of their outdated formatting. This can be troublesome when needing to use, share, or reference these files in modern environments due to compatibility issues. This API will allow you to convert and upgrade the 1997–2003 Word document format, DOC, to the current DOCX instantly.
To use this API, you first need to run the following command to install the SDK:
npm install cloudmersive-convert-api-client --save
Or, you can add this snippet to your package.json:
"dependencies": {
"cloudmersive-convert-api-client": "^2.4.8"
}
Then, you can call the function:
var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');
var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';var apiInstance = new CloudmersiveConvertApiClient.ConvertDocumentApi();var inputFile = Buffer.from(fs.readFileSync("C:\\temp\\inputfile").buffer); // 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.convertDocumentDocToDocx(inputFile, callback);
Now you can rest assured that your documents can be accessed whenever you need them without stress.
The API Key for this function can be retrieved from the Cloudmersive website at no cost and with no commitment. This will give you access to 800 monthly calls across our entire API library.