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

Free Support Forum - aspose.com

Comparison Document With Only Format Revisions


We want to compare two word documents and create a comparison document with only format revisions i.e., without any revisions related to change in content like Insertion, deletions and moving.

I tried following code to achieve this requirement:

void performCompare(){
Document doc1=new Document(“10kPart.docx”);
Document doc2=new Document(“Formatting And Content Changes.docx”);
doc1.compare(doc2, “Manisha” new Date());

// Get changes
RevisionCollection revisionCollection = doc1.getRevisions();
if (revisionCollection == null) {
prn("\n***** No revisions found! \n");
} else {
Found " + revisionCollection.getCount() + " revisions *****\n");

for (int index = 0; index < revisionCollection.getCount(); index++) {
Revision revision = revisionCollection.get(index);
if (revision.getRevisionType() == RevisionType.DELETION || revision.getRevisionType() == RevisionType.INSERTION ||
revision.getRevisionType() == RevisionType.MOVING) {



doc1.save(“Aspose_Formatting And Content Changes.docx”);

In the comparison document, we are seeing both format changes and content changes after we rejected all the content related revisions.

Please let me know if we are approaching this problem correctly. Is there something wrong in the code above? Are we required to do something else to achieve this?

Please help us in resolving this issue.

The sample documents are attached with this post for your reference.


Hi Manisha,

Thanks for your inquiry. Please use the following code:
Document doc1 = new Document(getMyDir() + “10kPart.docx”);
Document doc2 = new Document(getMyDir() + “Formatting And Content Changes.docx”);

doc1.compare(doc2, “Manisha”, new Date());

ArrayList revisionsToRemove = new ArrayList();
for (Revision rev : (Iterable<Revision>) doc1.getRevisions())
if (rev.getRevisionType() != RevisionType.FORMAT_CHANGE)

for (Revision rev : (Iterable<Revision>) revisionsToRemove)

doc1.save(getMyDir() + “15.8.0.docx”);

I hope, this helps.

Best regards,