This topic entails the process to insert comments in DOCX with Nodej.s REST API. We will use Aspose.Words for Nodej.s Cloud SDK to add a Comment into Word Document with Nodej.s Low Code API. You will obtain all the details to set the development environment and follow the given steps and Nodej.s REST API Code.
Prerequisite
- Create an account and get API credentials to insert comments in the DOC file
- Download Aspose.Words Cloud SDK for Nodej.s to include comments in a Word file
- Setup Nodej.s solution project with the above SDK to add the DOCX comments
Steps to Insert Comments into Word Document with Nodej.s REST API
- Set Client ID and Client Secret for the API to add Comments in a Word file
- Create an object of the WordsAPI class with your client account credentials
- Create an object of the CommentInsert by providing the comment start and end range
- Create a request to add comments using an instance of the InsertCommentOnlineRequest by providing the file name
- Insert the Comments in the Word document online using the InsertComment method
- Download the generated file from the cloud using the stream inside the response.Documents dictionary
- Save the downloaded file stream as DOCX file on the disk
The aforementioned steps explain how to insert comments into Word Document with Nodej.s REST API. We will commence the process by initializing the WordsApi class instance using the ClientSecret and ClientId, which is then followed by creating the InsertComment class instance by setting the range for comment start and range. We will then create the InsertCommentOnlineRequest request and use the InsertCommentOnline to obtain the DOCX file stream with added comments. Finally, we will save the file stream with added comments on the disk as DOCX file.
Code to Add Comments in Word Document with Nodej.s REST API
This sample code demonstrates the process to create comments in DOCX with Nodej.s Low Code API. The CommentInsert class exposes the properties to set the range for comments start and end, comment initials, author and text. You can add multiple comments inside the document as well. The file name that we will set for the requesInsertCommentOnlineRequest, will be used to extract the respective document file stream from the response object.
In this topic, we have learned to add comments in Word document with Nodej.s REST API. If you are looking to create a Word Document, refer to the article on how to create a Word File with Nodej.s REST API.