Hello team :). I have 2 supposedly identical documets:
d1.docx (1.1 MB)
d2.docx (1.0 MB)
They look the same and i can’t find any difference, but if I use Document.Compare method it creates 2 revisions for (insertion+deletion). Shape is parent Node for these revisions.
How can I find out how the documents differ?
@N.Kononovich Aspose.Words behaves the same way as MS Word does. MS Word also detects difference in image in your documents. You are right visually documents looks the same, but internally images representation is slightly different. Most likely this difference is detected by both MS Word and Aspose.Words.
Thak you for your reply!
We are apgrading our Aspose.Words version from 16.7 to 21.2. And both of documents were created with Aspose. Something like that:
using (Stream stream = File.Open("pic.png", FileMode.Open))
{
Words.Document d1 = new Words.Document();
DocumentBuilder b1 = new DocumentBuilder(d1);
System.Drawing.Image im = System.Drawing.Image.FromStream(imageStream);
b1.InsertImage(im);
}
And we are expectig resulting documets will be the same.
So to achieve compatibility we should change the code or we should just ignore these revesions?
@N.Kononovich In the d1.docx
document (generated by 16.7) version AspectRatioLocked
option is set for the image. Also, ids of DML are different in the documents. You can set or reset AspectRatioLocked
option for the shape and set CompareOptions.IgnoreDmlUniqueId
option. In this case Aspose.Words does not detect difference in the documents:
Document doc1 = new Document(@"C:\Temp\d1.docx");
Document doc2 = new Document(@"C:\Temp\d2.docx");
Shape s = (Shape)doc1.GetChild(NodeType.Shape, 0, true);
s.AspectRatioLocked = false;
CompareOptions options = new CompareOptions();
options.IgnoreDmlUniqueId = true;
doc1.Compare(doc2, "test", DateTime.Now, options);
doc1.Save(@"C:\Temp\out.docx");