How to Convert DOCX to RTF using Node.js

Cloudmersive
2 min readDec 21, 2022

--

While DOCX certainly boasts a wide range of text editing and formatting capabilities, its compatibility with other word processing applications is much more limited than RTF (Rich Text Format). Thankfully, converting between these document types is easy: just copy & paste the ready-to-run Node.js code examples below, and you can easily call our DOCX to RTF Conversion API. It’s free to use, too — just register a free account on our website (this provides a limit of 800 API calls per month & no commitments), and you’re ready to make your conversion.

Your first step is to install the Node.js SDK; you can do so by running the below command:

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

Next, call the function, and include your API key in the appropriate snippet (indicated in the code comments):

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.convertDocumentDocxToRtf(inputFile, callback);

All done — nice and easy!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet