Document.compare() does not recognise text box wrap mode changes, changes are not highlighted, revision count is 0.
Code snippet:
// Create the original document
Document docOriginal = new Document();
DocumentBuilder builder = new DocumentBuilder(docOriginal);
// Insert a textbox
Shape textBox = builder.insertShape(ShapeType.TEXT_BOX, 50, 50);
builder.moveTo(textBox.getFirstParagraph());
builder.write("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
// Create a clone of our document, change text box wrap mode in the clone
Document docEdited = (Document)docOriginal.deepClone(true);
Shape shapeEdited = (Shape) docEdited.getChildNodes(NodeType.SHAPE, true).get(0);
shapeEdited.getTextBox().setTextBoxWrapMode(TextBoxWrapMode.NONE);
// Apply text box compare options
CompareOptions compareOptions = new CompareOptions();
compareOptions.setIgnoreTextboxes(false);
docOriginal.compare(docEdited, "John Doe", new Date(), compareOptions);
System.out.println(docOriginal.getRevisions().getCount());
docOriginal PDF export:

docEdited PDF export:

Aspose.WORDS version: 24.9
@dfinsolutions
The issue you’re experiencing with Document.compare() not recognizing changes in the text box wrap mode may stem from the way the comparison is implemented in Aspose.Words. The CompareOptions you are using, specifically compareOptions.setIgnoreTextboxes(false);, should allow for text box changes to be considered, but it appears that the wrap mode change is not being detected.
Here are a few suggestions to troubleshoot and potentially resolve the issue:
-
Verify Wrap Mode Changes: Ensure that the text box wrap mode is indeed being changed in the docEdited document. You can print out the wrap mode before and after the change to confirm.
-
Update Aspose.Words: Ensure you are using the latest version of Aspose.Words, as updates may include bug fixes related to document comparison.
-
Manual Property Check: If the comparison does not highlight the changes, manually check the properties of the text box in both documents to see if they differ as expected.
-
Alternative Comparison Method: If the issue persists, consider exporting the documents to a format that allows for easier visual comparison (such as PDF) and manually reviewing the differences.
Here’s a minimal code snippet to check the wrap mode before and after the change:
System.out.println("Original Wrap Mode: " + shapeEdited.getTextBox().getTextBoxWrapMode());
shapeEdited.getTextBox().setTextBoxWrapMode(TextBoxWrapMode.NONE);
System.out.println("Edited Wrap Mode: " + shapeEdited.getTextBox().getTextBoxWrapMode());
If these steps do not resolve the issue, consider reaching out to the Aspose support forums for more specific guidance.
@dfinsolutions
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-28769
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.
As a temporary workaround, you can save the document before comparing:
// Create the original document
Document docOriginal = new Document();
DocumentBuilder builder = new DocumentBuilder(docOriginal);
// Insert a textbox
Shape textBox = builder.insertShape(ShapeType.TEXT_BOX, 50, 50);
builder.moveTo(textBox.getFirstParagraph());
builder.write("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
// Save document before comparing.
docOriginal.save(new ByteArrayOutputStream(), SaveFormat.DOCX);
// Create a clone of our document, change text box wrap mode in the clone
Document docEdited = (Document)docOriginal.deepClone(true);
Shape shapeEdited = (Shape)docEdited.getChildNodes(NodeType.SHAPE, true).get(0);
shapeEdited.getTextBox().setTextBoxWrapMode(TextBoxWrapMode.NONE);
// Save document before comparing.
docEdited.save(new ByteArrayOutputStream(), SaveFormat.DOCX);
// Apply text box compare options
CompareOptions compareOptions = new CompareOptions();
compareOptions.setIgnoreTextboxes(false);
docOriginal.compare(docEdited, "John Doe", new Date(), compareOptions);
System.out.println(docOriginal.getRevisions().getCount());