Compare Word Files with Different Images & Get Adjacent Deletion & Insertion Revisions (C# .NET)

Hello,

here is two documents with images, when i use aspose to compare them, it gives differences. if i compare manually the two images there are no difference. doc2.docx (36.0 KB)
doc1.docx (36.0 KB)

@miniseb31,

After an initial test with the licensed latest (21.5) version of Aspose.Words for .NET, we were unable to reproduce this issue on our end. Please see this output DOCX (21.5.docx (31.4 KB)) that we generated by using the following code.

Document doc1 = new Document("C:\\temp\\Doc1.docx");
Document doc2 = new Document("C:\\temp\\Doc2.docx");

doc1.Compare(doc2, "author", DateTime.Now);

doc1.Save("C:\\temp\\21.5.docx");

So, we suggest you to please upgrade to the latest 21.5 version of Aspose.Words for .NET.

hello
I retested with version 21.1, with word document generated by my application.

using the following documents
TestConductedCurrent_3.21.0.8.docx (89.3 KB)
TestConductedCurrent_Comparaison.docx (158.0 KB)

the result is :
Diff_TestConductedCurrent_3.21.0.8.docx (115.5 KB)

The images are marked as different but they are the same (i only used the following option:
CompareOptions options = new CompareOptions();
options.IgnoreDmlUniqueId = true;

@miniseb31,

We have logged this problem in our issue tracking system. Your ticket number is WORDSNET-22267. We will further look into the details of this problem and will keep you updated here on the status of the linked issue. We apologize for your inconvenience.

Code we used on our end for testing is:

Document doc1 = new Document("C:\\temp\\TestConductedCurrent_3.21.0.8.docx");
Document doc2 = new Document("C:\\temp\\TestConductedCurrent_Comparaison.docx");

Aspose.Words.Comparing.CompareOptions compareOptions = new Aspose.Words.Comparing.CompareOptions();
compareOptions.IgnoreDmlUniqueId = true;

doc1.Compare(doc2, "author", DateTime.Now, compareOptions);

doc1.Save("C:\\temp\\21.5.docx");

hello,
how from a Aspose.word.revision can i get the old image and the new image ? maybe i can compare myself the two images ?
I found the following code to get the image of the new image (but where can i found the old image meaning the one in the other document

Shape revisionNode = revision.ParentNode as Shape;
if (revisionNode != null)
{
    bool hasimage = revisionNode.HasImage;
}

@miniseb31,

If you compare two Word documents containing two different images by using MS Word 2019 desktop application (or Aspose.Words), they will then produce two Revisions in the final document (i.e. Insertions: 1 and Deletions: 1). Maybe you should check Parent Nodes of both relevant Revisions to get old and new images. I have also logged your query in our issue tracking system and will keep you posted here on any further details.

hello,
thanks for the advice, is there a way to know that two revision are linked each other for the same element (deletion and insertion) ?

@miniseb31,

Regarding WORDSNET-22267, please note that these Shapes are different in fill image bytes, although data length is the same, but content of data is different. Please note MS Word also marks these images as different.

Unfortunately, MS Word documents have no such functionality to determine what insertion revisions are linked to which deletion revisions. But, the comparison algorithm always places images being compared adjacent, i.e shape marked for deletion should be sibling of shape marked for insertion.