We're sorry Aspose doesn't work properply without JavaScript enabled.

Comments on word... while converting HTML to Word

Hi,

I want to add comment to the doc file while converting from HTML to DOC/PDF, wanted to know how to add a comment on particluar text (from existing HTML) …

What I did is :- Created a document object, Load html in that document

I have taken some reference from link
https://blog.aspose.com/category/words/

Regards,

Divesh Salian

Hi Divesh,

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.

The CommentRangeStart and CommentRangeEnd 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.

// 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();
Paragraph paragraph = (Paragraph)nodes[4];
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!!!"));
comment.appendChild(commentParagraph);