Comments are a great way to share your feedback/input over certain sections/paragraphs within a Word document. Furthermore, in a multi-user environment, it provides an easy and effective way to collaborate and comment on document drafts. Nevertheless, even individual users find the feature handy for adding notes and reminders.
Aspose.Words Cloud is a leading REST API offering features to create as well as manipulate existing MS Word, OpenOffice document formats. It provides complete support for manipulating comments inside an MS word document. This article covers the following features supported by the API
You can leverage to read all or specific comments from the document. The GetComments method provides the capabilities to read the user comments from DOCX file. Specified below is a cURL command which you may use to read the comments on the command prompt
cURL command
Please note that in order to read comments, you need to provide the details regarding documents stored on cloud storage, as well as only authorized users, get the permissions to access the APIs. Therefore, you need to first retrieve the JWT authentication token and use it in the command as mentioned above.
In order to read a particular comment from the document, please follow the steps specified below
Initialize an instance of WordsApi class
Create an object of GetCommentRequest class where we provide the input Volume 1.docx file name and comment index value as input arguments
Finally, initialize an object of CommentResponse while passing the value returned from GetComment(..) method.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The API also offers the feature to get all comments from the document (in case we do not want to traverse between individuals). For this requirement, you need to create an instance of GetCommentsRequest, CommentsResponse classes, and call the GetComments(..) method of theWordsApi object.
Insert comments in Word document
The API is also capable of adding/inserting new comment objects in a word document.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create an object of NodeLink which defines the comment NodeID
A new object of DocumentPosition class is created that defines RangeStart and RangeEnd values.
Create an object of CommentUpdate which defines, comment Initials, Author name, RangeStart & RangeEnd details by assigning DocumentPosition instance value. and the text to be updated in the comment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create an instance of DeleteCommentRequest class which takes an input file and index of comment as an argument
Finally the DeleteComment(…) method having DeleteCommentRequest object as an argument
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters