Showing difference in un-changed content after comparison

Hello, we are comparing 2 documents. 1st is standard document and 2nd is user uploaded document after modification.
when we are comparing it using Aspose(in online aspose site and our c# project using aspose), then it is showing difference in unchanged content like this. and this is in whole document

image.png (207.5 KB)

i am attaching 3 docx file for the refrence:
Our Standard file: orignal.docx (50.2 KB)

User Uploaded file: A401-2017-Working draft- Offline editing (1) (1).docx (50.2 KB)

Comparison Result: compared.docx (87.0 KB)

@ttinwala

Could you please provide more details about the specific issue you are encountering with the comparison of the documents? Are you looking for a way to suppress the display of unchanged content differences?

Yes, we are using Aspose.Words in our project to compare the document. But it is showing difference for unchenged content. so we are looking for the solution how we can resolve this issue.
this is our code after setting the license.

//uploaded document
var docA = new Aspose.Words.Document(doc2);
//original document
var docB = new Aspose.Words.Document(doc1);
docA.AcceptAllRevisions();
docB.AcceptAllRevisions();
CompareOptions compareOptions = new CompareOptions();
compareOptions.Granularity = Granularity.CharLevel;
docB.Compare(docA, "Test Author", DateTime.Now, compareOptions);
MemoryStream stream = new MemoryStream();
docA.Save("orignal.docx");
docB.Save("uploaded.docx");
docB.Save(stream, Aspose.Words.SaveFormat.Docx);
// docB.Save("compare.docx");

@ttinwala I am afraid I cannot reproduce the problem with the attached documents. I used your code for testing:

//uploaded document
var docA = new Aspose.Words.Document(@"C:\Temp\v1.docx");
//original document
var docB = new Aspose.Words.Document(@"C:\Temp\v2.docx");
docA.AcceptAllRevisions();
docB.AcceptAllRevisions();
CompareOptions compareOptions = new CompareOptions();
compareOptions.Granularity = Granularity.CharLevel;
docB.Compare(docA, "Test Author", DateTime.Now, compareOptions);
docB.Save(@"C:\Temp\out.docx");

And here is the output:
out.docx (50.3 KB)

Please make sure you have attached the correct input document in the initial post.

Could you please check with this file:

docA.docx (50.2 KB)

docB.docx (74.4 KB)

@ttinwala Thank you for additional information. Yes, here are differences with these documents:
out.docx (87.3 KB)

However, if compare them using MS Word I see the same differences:
ms.docx (121.9 KB)

So Aspose.Words behavior is correct in this case.

Hi, I have checked this again… word file is showing difference because of breakable and unbreakable spaces…
is there any mechanism to ignore this…

image.jpg (132.1 KB)

@ttinwala I am afraid there is no direct way to ignore the difference between regular whitespace and unbreakable space.
You can try replace non-breaking spaces with regular spaces:

Document v1 = new Document(@"C:\Temp\docA.docx");
Document v2 = new Document(@"C:\Temp\docB.docx");

// Replace non-breaking spaces with regular spaces.
v1.Range.Replace(ControlChar.NonBreakingSpace, " ");
v2.Range.Replace(ControlChar.NonBreakingSpace, " ");

v1.Compare(v2, "AW", DateTime.Now);
Console.WriteLine(v1.HasRevisions);
v1.Save(@"C:\Temp\out.docx");
1 Like

Thank you for the help…

1 Like