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

Free Support Forum - aspose.com

Extract comments and comment target

I have a group of documents that someone highlighted words in it and then added a comment. I need to extract the document and (most importantly) the highlighted word associated with that target. Is this possible with the latest version of ASPOSE.WORDS (.NET)?

Thanks,

Todd

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. You can get collection of comments using the following code:

//Open document

Document doc = new Document(@"Test155\in.doc");

//Get collection of comments from the docuemnt

NodeCollection comments = doc.GetChildNodes(NodeType.Comment, true);

//Loop through all comments

foreach (Comment comm in comments)

{

Console.WriteLine(string.Format("Comment text: {0} \tComment author: {1} \tComment date: {2}", comm.ToTxt(), comm.Author, comm.DateTime));

}

Unfortunately, you cannot get commented text (text associated with comment). This is a known issue #1012 in our defect database. You can only get parent note of the comment using Comment.ParentNode or Comment.ParentParagraph.

Best regards.

It is very important for us to be able to determine what text (specifically) the comment is associated with. I know I can do this with Office automation I was just hoping to avoid using that mess. Can I hope to see this in an upcomming version?

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Unfortunately, I cannot provide you any reliable estimate regarding this issue at the moment. I will notify you as soon as it is resolved, but I am afraid it could take much time.

Best regards.

That is very dissapointing. It almost seems common sense to ensure a comment knows what portion of the text it is commenting on.

I actually just converted a docx document to doc that had comments in it. During the conversion the highlighted text (that the comment belongs too) is no longer highlighted. The comment just sits at the end of the line or word(s) that it once highlighted.

I really need this issue resolved as my options are greatly limited.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Unfortunately, I cannot promise you anything regarding this issue. Comments are not very popular feature, because only few customers asked about such feature. Sorry for inconvenience.

Best regards.

We are happy to notify you that the latest version of Aspose.Words supports commented ranges. You can download the latest version fo Aspose.Words from here..

Here is a simple code example, which allows insertion commented range into the document:

// Create an empty document and DocumentBuilder object.

Document doc = new Document();

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);

// Create CommentRangeStart and CommentRangeEnd.

int commentId = 0;

CommentRangeStart start = new CommentRangeStart(doc, commentId);

CommentRangeEnd end = new CommentRangeEnd(doc, commentId);

// Insert some text into the document.

builder.Write("This is text before comment ");

// Insert comment and comment range start.

builder.InsertNode(comment);

builder.InsertNode(start);

// Insert some more text.

builder.Write("This is commented text ");

// Insert end of comment range.

builder.InsertNode(end);

// And finaly insert some more text.

builder.Write("This is text aftr comment");

// Save output document.

doc.Save(@"Test001\out.doc");

Best regards,