Hi,
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(){
In the comparison document, we are seeing both format changes and content changes after we rejected all the content related revisions.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 {
prn("\n 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) {
revision.reject();
}
}
}
doc1.save(“Aspose_Formatting And Content Changes.docx”);
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.
Thanks
Manisha