Dear Sir:
I have a question : I have an existing word ducument , and I want to insert some comments on the document in the given page , row and column, so how can I do this? Thank you for your answer!
Dear Wang,
Thank you for your question.
Unfortunately due to flow format of .doc/.docx files you cannot use page, row or column data to insert something into document.
To define exact location to insert comment I would recommend using bookmark. You can mark word/phrase you want comment by bookmark and then use the following code:
Bookmark bookmark = doc.Range.Bookmarks["ttc"];
// Insert a comment.
Comment comment = new Comment(doc, "xyx", string.Empty, System.DateTime.Now);
comment.SetText("Comment for given word");
CommentRangeStart start = new CommentRangeStart(doc, comment.Id);
CommentRangeEnd end = new CommentRangeEnd(doc, comment.Id);
bookmark.BookmarkStart.ParentNode.InsertBefore(comment, bookmark.BookmarkStart);
bookmark.BookmarkStart.ParentNode.InsertBefore(start, bookmark.BookmarkStart);
bookmark.BookmarkEnd.ParentNode.InsertAfter(end, bookmark.BookmarkEnd);
bookmark.Remove(); // bookmark deleting at your option
Another way to define location of word/phrase is to implement IReplacingCallback to search word into the document and comment it. How to do this please see here https://forum.aspose.com/t/55625
Hope this helps.
Thank you for your answer,I’ll try it.