Thanks for your inquiry. A comment in a document is imported as a Comment
node in the Aspose.Words DOM. The range of a comment can span over various parts of the document text, including over many paragraphs and tables.
nodes define the area of the document that the comment is applied to. The Comment node defines the actual content of the comment and provides members to access the comment properties such as Author and Time. All three comment nodes are related through the use of the ID properties on each node.
Please use the following code snippet to add comment to a paragraph in a document.
// Open an existing document to add comments to a paragraph.
Document doc = new Document(“D:\in.html”);
Node nodes = doc.getChildNodes(NodeType.PARAGRAPH, true).toArray();
//E.g this is the Paragraph to which comments will added
Paragraph paragraph = (Paragraph)nodes;
DocumentBuilder builder = new DocumentBuilder(doc);
// Create a Comment.
Comment comment = new Comment(doc);
// Insert some text into the comment.
Paragraph commentParagraph = new Paragraph(doc);
commentParagraph.appendChild(new Run(doc, “This is comment!!!”));
//Move to paragraph where comments will be added
// Insert comment
// Save output document.