Getting incorrect revision information using Aspose.words Java library

Hi Team,

I’m using Aspose.words for Java to get revision info (like the number of insertions, deletions, and format changes) with the code below. But I found that sometimes, the revision info is incorrect since the counts don’t match MS Word review counts. I’ve attached files and screenshots for you to check out. It’s really important for us to show this info accurately, so any help would be great.

Code to check revision information:

public static void main(String[] args) throws Exception {
	loadAsposeLicense();
	Document original = new Document("./<file-with-revision-info>.docx");
	revisionInformation(original);
}

public static void revisionInformation(Document doc) throws Exception {
	HashMap<String, Integer> revisionMap = new HashMap<>();
	RevisionCollection revisions = doc.getRevisions();
	Iterator<RevisionGroup> e = revisions.getGroups().iterator();
	while (e.hasNext()) {
		RevisionGroup revisionGroup = e.next();
		int revisionIndex = revisionGroup.getRevisionType();
		String revisionName = RevisionType.toString(revisionIndex);
		if (revisionMap.containsKey(revisionName)) {
			revisionMap.put(revisionName, revisionMap.get(revisionName) + 1);
		} else {
			revisionMap.put(revisionName, 1);
		}
	}
	// printing counts
	System.out.println("===== Revision information =====");
	for (String key : revisionMap.keySet()) {
		System.out.println(key + ": " + revisionMap.get(key));
	}
}

Sample file:
test_sample.docx (99.6 KB)

MS word revision information for sample file

Aspose.words revision information for sample file

@Kldv

It seems that you are experiencing discrepancies between the revision information reported by Aspose.Words for Java and what is shown in Microsoft Word. This can happen due to various reasons, including differences in how revisions are tracked and reported by the two applications.

Here are a few suggestions to help you troubleshoot and potentially resolve the issue:

  1. Check Document Loading Options: Ensure that you are using the correct loading options when opening the document. You might want to specify the MS Word version that matches the document’s format. This can be done using the LoadOptions class, where you can set the mswVersion property to match the version of MS Word that was used to create or edit the document.

    LoadOptions loadOptions = new LoadOptions();
    loadOptions.setMswVersion(MsWordVersion.WORD_2019); // or the appropriate version
    Document doc = new Document("path/to/document.docx", loadOptions);
    
  2. Review Revision Types: You can iterate through the revisions in the document and print out their types and details. This will help you understand what types of revisions are being tracked and if any are being missed.

    for (Revision revision : doc.getRevisions()) {
        System.out.println("Type: " + revision.getRevisionType());
        System.out.println("Author: " + revision.getAuthor());
        System.out.println("Date: " + revision.getDateTime());
    }
    
  3. Compare with MS Word: If possible, manually compare the revision counts from Aspose.Words with those in MS Word. This can help identify specific types of revisions that are not being counted correctly.

  4. Update Aspose.Words: Ensure that you are using the latest version of Aspose.Words for Java, as updates may include bug fixes and improvements related to revision tracking.

  5. Consult Documentation: Review the Aspose.Words documentation for any specific notes on revision handling. There may be additional settings or methods that can help align the revision information with what is shown in MS Word.

If the issue persists after trying these suggestions, consider providing a minimal reproducible example along with the document in question to the Aspose support team for further assistance.

Feel free to reach out if you have any more questions or need further clarification!

It looks like this issue is happening with .doc files too. Can someone check if it’s a known bug or if there’s something wrong with my code that’s affecting the revision info ?

Sample file:
sample_file.zip (37.9 KB)

MS word revision info:

Aspose.words revision info:

@Kldv
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-27982

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like