How to get comments from a Word DOCX document hierarchically in Node.JS
Using Node.JS to retrieve comments from a DOCX file is generally not too difficult on its own. However, the difficulty gets magnified considerably when this data is required in a hierarchical form. No fretting, though, as we still have an easy solution that will power you to the finish.
Let’s begin by adding this reference for importing our client.
"dependencies": {
"cloudmersive-convert-api-client": "^2.1.6"
}
This next block of code will demonstrate how to instance the Edit Document API using a key, then the function call for editDocumentDocxGetCommentsHierarchical.
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.EditDocumentApi();var reqConfig = new CloudmersiveConvertApiClient.GetDocxGetCommentsHierarchicalRequest(); // GetDocxGetCommentsHierarchicalRequest | Document input requestvar callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.editDocumentDocxGetCommentsHierarchical(reqConfig, callback);
And there you have it! The comment hierarchy will be returned to you a short time after you make your request.