How to merge two Word DOCX files together in Node.JS

You are not going to believe just how easy it is to merge DOCX files with this one simple trick.

Let’s start with installing our API client with NPM install.

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

Next, use this block of code to call our merging function.

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.MergeDocumentApi();var inputFile1 = "/path/to/file"; // File | First input file to perform the operation on.var inputFile2 = "/path/to/file"; // File | Second input file to perform the operation on (more than 2 can be supplied).var callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.mergeDocumentDocx(inputFile1, inputFile2, callback);

Throw in your DOCX files and you are done! There are many more time-saving APIs like this in our library, so take a look! They cover all kinds of useful stuff, including converting document files to PDF, optical character recognition, and spreadsheet editing.

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store