Document.Revisions returns incorrect revisions using Java

TrackChangesSampleForAspose.zip (11.1 KB)
Aspose Team,

Using the Java Aspose 19.11 Word library, we’re trying to identify the document revision data from various DOCX documents. However, when the included sample document is tested, we see that the document appears to have an empty revision collection. When viewing the document in Microsoft Word, however, it’s apparent that there are document revisions.

Here’s a sample bit of code meant to show the relevant pieces:

private static final String lineReturn = “\r\n”;
Document doc = new Document(path);
StringBuilder sb = new StringBuilder();
for (Revision rev : doc.getRevisions())
{
Node node = rev.getParentNode();
if(rev.getRevisionType() != RevisionType.FORMAT_CHANGE) {
if (sb.length() > 0) {
sb.append(lineReturn);
}
sb.append("Location: " + Node.nodeTypeToString(node.getNodeType()) + lineReturn);
sb.append("Author: " + rev.getAuthor() + lineReturn);
sb.append("Date: " + rev.getDateTime() + lineReturn);
sb.append("Type: " + RevisionType.getName(rev.getRevisionType()) + lineReturn);
sb.append("Text: " + rev.getParentNode().toString(SaveFormat.TEXT) + lineReturn);
}
}
if(sb.length() > 0) {
Logger.Log(“Doc Revisions=” + sb.toString());
}

I’ve attached the DOCX file that exhibits the problem that we’re seeing. Please advise
.
Thanks for your help.
Jerry

@jmuth

Your document contains comments. Following code example shows how to get the comments.

Document doc = new Document(MyDir + "Test for hidden content track changes.docx");
for(Comment comment :(Iterable<Comment>)doc.getChildNodes(NodeType.COMMENT, true))
{
    System.out.println(comment.getText());
}

Tahir,

Thank you for the prompt reply. However, as I noted in the bug description, the issue is not with retrieving document comments - the issue is with fetching document revisions. Can you please review again and look at the code sample provided? Thank you.

Jerry

@jmuth

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-20464 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Thank you for confirming this bug, Tahir. We look forward to hearing about a resolution to this issue.

@jmuth

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

@jmuth

It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-20464) as ‘Not a Bug’.

Actually document has no revisions, at least it has no edit or formatting revisions. In contrary it has comments and MS Word shows comments in Revision Pane along all other revisions.

To find comments you may use following code example.

Document doc = new Document(MyDir + "Test for hidden content track changes.docx");
foreach (Comment comment in doc.GetChildNodes(NodeType.Comment, true))
{
    Console.WriteLine(comment.Author);
}

Thank you, Tahir. You are correct - there are only comments in the document I provided. I had two similarly named documents confused and I agree that Aspose Words is working correctly on the document I submitted. Thank you for your time.

@jmuth

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.