How to Remove All Comments from a Word Document in Node.JS

It can be frustrating when working with a large, collaborative document, only to print it and realize that a comment was left unresolved, changing the format of the printed copy. While you can choose to go into the Word file and delete these comments, allowing an API to automate the process for you will take that one extra task off of your heavy workload. This API will remove all comments from a document instantly, and the only necessary parameter is the input file.

Image for post
Image for post

To use this API, 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.EditDocumentApi();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) {
} else {
console.log('API called successfully. Returned data: ' + data);
apiInstance.editDocumentDocxRemoveAllComments(inputFile, callback);

After this, you can be confident that your finished product will look exactly as it should with no comments left unchecked.

The API Key for this function can be retrieved at no cost and with no commitment on the Cloudmersive website. This will give you access to 800 monthly calls across our entire library of 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