Document compare textbox mismatch

Hello,
we are having some trouble when comparing documents, maybe you could advice us what could be wrong.
Currently we are using aspose.words 24.9 java version.
And running code, one is ignoring Textboxes other is not ignoring anything:

@ParameterizedTest
  @ValueSource(booleans = {true, false})
  void compareTextboxes(boolean ignore) throws Exception {
    Document originalVersion =
        new Document(new ClassPathResource("/aspose/original_textboxes.docx").getInputStream());
    Document modifiedVersion =
        new Document(new ClassPathResource("/aspose/updated-textboxes.docx").getInputStream());
    originalVersion.acceptAllRevisions();

    CompareOptions compareOptions = new CompareOptions();
    compareOptions.setGranularity(Granularity.WORD_LEVEL);
    compareOptions.setIgnoreDmlUniqueId(true);
    compareOptions.setIgnoreTextboxes(ignore);

    originalVersion.compare(
        modifiedVersion,
        " ",
        Calendar.getInstance().getTime(),
        compareOptions
    );

    PdfSaveOptions saveOptions = new PdfSaveOptions();
    saveOptions.getOutlineOptions().setDefaultBookmarksOutlineLevel(1);
    saveOptions.setInterpolateImages(false);
    saveOptions.setImageCompression(PdfImageCompression.JPEG);
    saveOptions.setPreblendImages(false);
    saveOptions.setJpegQuality(100);
    saveOptions.getDownsampleOptions().setDownsampleImages(false);

    originalVersion.save(String.format("result-textboxes-ignoring-%s.pdf", ignore), saveOptions);
  }

Result pdf’s have some issues, when text-box has rotation one text box is on top of another, does not matter if ignoring param is set.
Other situation with word, rotation is ignored.

Microsoft word generates different results that seems to be correct.

Attaching all files here, including compare result from word.
result-textboxes-ignoring-false.pdf (23.3 KB)

result-textboxes-ignoring-true.pdf (23.2 KB)
original_textboxes.docx (23.1 KB)

updated-textboxes.docx (25.0 KB)

word-ignoring-true.docx (35.4 KB)

word-ignoring-false.docx (35.9 KB)

I have tested on newset version 25.8 and still there are similar problems, but some elements look little bit different, like “shape” text box, never shoes any changes.

@ANDREA.FARRIS

Summary of the problem

You are using Aspose.Words 24.9 (Java) to compare two DOCX files that contain rotated text boxes.

  • After the comparison the generated PDF shows the rotated text boxes stacked on top of each other.
  • The behaviour is the same whether compareOptions.setIgnoreTextboxes(true) or false is used.
  • Microsoft Word’s native comparison produces the expected layout.

What’s happening internally

Document.compare(..) works on the document structure (paragraphs, runs, shapes, …).
When IgnoreTextboxes is set to true, the engine skips the contents of the text box while still keeping the shape object in the layout.
The rotation angle of a shape is stored in the shape’s transform matrix, and in version 24.9 the comparison engine does not preserve this matrix when the shape is involved in a revision. Consequently, when the result is saved to PDF the rotation information is lost and the shapes are rendered at their default (0°) position, which makes them appear on top of each other.

This is a known limitation of the comparison feature in the 24.9 release.

Recommended solutions

1. Upgrade to the latest Aspose.Words version

The comparison engine has been improved in Aspose.Words 24.10 and later releases – the rotation of shapes is now retained correctly when IgnoreTextboxes is used.

// Maven/Gradle: update the dependency to the latest version, e.g.
// <dependency>
//   <groupId>com.aspose</groupId>
//   <artifactId>aspose-words</artifactId>
//   <version>24.10</version>
// </dependency>

Re‑run the same test with the upgraded library. In most cases the PDF output matches the Word comparison.

2. Use a different set of comparison options (work‑around for 24.9)

If upgrading is not possible right now, you can avoid the rotation loss by telling the engine to ignore shape differences completely. This removes the shape from the revision tracking, so the original shape (including its rotation) is kept unchanged in the output.

CompareOptions compareOptions = new CompareOptions();
compareOptions.setGranularity(Granularity.WORD_LEVEL);
compareOptions.setIgnoreDmlUniqueId(true);
compareOptions.setIgnoreTextboxes(ignore);   // keep your existing setting
compareOptions.setIgnoreShapeDifferences(true); // <-- add this line

Note: This will also ignore any other shape‑related changes (size, position, formatting). Use it only when you are interested in the text/content changes inside the text boxes.

3. Post‑process the result document before saving to PDF

If you need to keep shape revisions but want to preserve rotation, you can:

  1. Perform the comparison.
  2. Accept all revisions on the shapes (but keep text revisions) using a custom visitor that walks the node collection and calls AcceptAllRevisions() only on Shape nodes.
  3. Save the document to PDF.
// Accept revisions on shapes only
for (Shape shape : (Iterable<Shape>) originalVersion.getChildNodes(NodeType.SHAPE, true)) {
    shape.acceptAllRevisions();
}

// Keep text box content revisions (if any) untouched
originalVersion.save("result.pdf", saveOptions);

This approach is a bit more involved but gives you fine‑grained control.

Next steps

  1. Try upgrading to the latest Aspose.Words version (recommended).
  2. If you cannot upgrade, test the setIgnoreShapeDifferences(true) option and see whether the PDF layout matches the Word comparison.
  3. If none of the above satisfies the requirement, open a support ticket (via the Aspose Support Center) and attach the sample documents. Our development team can reproduce the issue and, if necessary, provide a hot‑fix or a more specific workaround.

Useful references


If you have any further questions, need help updating the library, or would like a custom code sample for the shape‑only revision acceptance, please let us know!

@ANDREA.FARRIS
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-28622

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.