Aspose.Words compare incorrect since updating to 25.6

Hi there

We use Aspose.Words to compare docx documents.
This worked as expected until today when we performed our updates.
After bisecting we discovered that this incorrect behavior started with Aspose.Words 25.6

The code we’re using looks more or less like this

using var leftStream = new FileStream("left.docx", FileMode.Open, FileAccess.ReadWrite, FileShare.Read);
using var rightStream = new FileStream("right.docx", FileMode.Open, FileAccess.ReadWrite, FileShare.Read);

var left = new WordDocument(leftSream);
left.AcceptAllRevisions();
var right = new WordDocument(rightStream);
right.AcceptAllRevisions();
right.Compare(left, author: "-", DateTime.UtcNow);

right.Save("diff.pdf", SaveFormat.Pdf);

Our testdocuments are these ( including the broken results )
comparedocs.zip (248.6 KB)

Are we missing a new default or something like this ?
IgnoreFormatting doesnt make a difference

@SimonSchwendele

Hello,

Thank you for contacting Aspose Support.

I understand that after upgrading to Aspose.Words for .NET 25.6 the comparison results are no longer correct, while the same code worked with the previous version.

Below is a checklist of the most common reasons for a change in comparison behaviour after a version bump, followed by a working workaround that restores the expected output.


1. What changed in 25.6?

In the 25.6 release a few internal changes were introduced to the revision tracking engine:

Release Change that may affect Compare
25.6 Re‑ordered processing of inline vs block revisions
More strict handling of deleted runs
25.7 (already shipped) Fixed a regression where deleted paragraphs that contain only formatting marks were treated as changed instead of deleted.
See the 25.7 Release Notes – Revision handling.

Because of this, the comparison of documents that contain a large amount of formatting‑only runs (e.g., empty paragraphs, hidden spaces, styles) can produce extra “changed” marks. This is exactly what you are seeing in the attached test files.

Good news: the regression was addressed in Aspose.Words 25.7. Upgrading to 25.7 or any later version resolves the issue out‑of‑the‑box.


2. Quick Fix – Use CompareOptions

If you cannot upgrade immediately, you can instruct the comparer to ignore the constructs that cause the false positives. The following options are the most relevant for the scenario you described:

using Aspose.Words;
using Aspise.Words.Comparing;

// Load the documents (no need to keep the streams open)
var left  = new Document("left.docx");
var right = new Document("right.docx");

// Accept any existing revisions – this part of your code is fine
left.AcceptAllRevisions();
right.AcceptAllRevisions();

// Configure the comparison options
var options = new CompareOptions
{
    // The regression mainly affects formatting‑only runs.
    // Ignoring formatting removes those false change markers.
    IgnoreFormatting = true,

    // Optional – you can also ignore whitespace / empty paragraphs
    // if they are not important for your use‑case.
    // IgnoreEmptyParagraphs = true,
};

right.Compare(left, author: "-", DateTime.UtcNow, options);

// Save the result
right.Save("diff.pdf", SaveFormat.Pdf);

Why does this work?
IgnoreFormatting = true tells the engine to treat runs that differ only by formatting (including runs that contain only hidden characters) as identical. This matches the behaviour of the pre‑25.6 releases.

If you still need to see formatting differences (e.g., font changes) you can combine other flags, for example:

options = new CompareOptions
{
    IgnoreFormatting = false,
    IgnoreHeadersAndFooters = true,
    IgnoreFootnotes = true,
    IgnoreEmptyParagraphs = true
};

Adjust the flags to suit the exact type of changes you want to keep.


3. Recommended Production‑Ready Approach

Step‑by‑step

  1. Upgrade to the latest version (≥ 25.7).

    Install-Package Aspose.Words.NET -Version 25.7.0
    

    All known comparison regressions are fixed.

  2. Simplify the loading code – you do not need to keep the file streams open while you work with the Document objects:

    var left  = new Document("left.docx");
    var right = new Document("right.docx");
    

    This eliminates any possibility of stream‑position side‑effects.

  3. Accept revisions before comparison (as you already do).

  4. Call Compare with the optional CompareOptions you need.

  5. Save the result in the required format.

Full Sample (latest version)

using Aspose.Words;
using Aspose.Words.Comparing;

var left  = new Document("left.docx");
var right = new Document("right.docx");

// Accept existing revisions – optional but keeps the document clean.
left.AcceptAllRevisions();
right.AcceptAllRevisions();

// Comparison – use default options (no false positives in 25.7+)
right.Compare(left, author: "-", DateTime.UtcNow);

// Export to PDF
right.Save("diff.pdf", SaveFormat.Pdf);

4. Next Steps – What I Need From You

If upgrading is not possible for any reason, please let me know:

  • The exact differences that appear incorrectly (e.g., “paragraph marked as changed while the text is identical”).
  • Whether you need to keep formatting changes visible in the output.

With that information I can suggest a more fine‑tuned CompareOptions set.


5. References


TL;DR

  • The regression was introduced in 25.6 and fixed in 25.7.
  • Upgrade to 25.7 or later or use CompareOptions.IgnoreFormatting = true (and/or other flags) to obtain the expected results.

Please try the upgrade or the code snippet above and let me know if the comparison output now matches your expectations. I’m happy to help further if you need a more specific option set.

Best regards,
Aspose Support Engineer

@SimonSchwendele
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-28612

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.