Compare Word DOCX Documents and Retain Cross References (REF Fields) | C# .NET

aspose-compare.docx (10.3 KB)
no-xref.docx (12.9 KB)
word-compare.docx (13.1 KB)
xref.docx (13.0 KB)

Attached are two files, no-xref.docx and xref.docx. They are the same, but xref.docx has some additional text and a cross-reference.

The file aspose-compare.docx was created by comparing xref.docx (as modified file) against no-xref.docx (as original file) using Document.Compare. When you go into the document, highlight the inserted cross-reference and run Update Field from the context menu, the result is Error! Reference source not found. This is especially a problem when the comparison file must be saved as PDF. Since saving as PDF (via Aspose) runs the Update Fields operation internally, the resulting PDF shows Error! Reference source not found. instead of the referenced paragraph number.

The file word-compare.docx was created by running the same comparison using Word’s built-in Compare feature. Running Update Field in this file does not break the cross-reference; it behaves as expected. So, this appears to be a bug in the Aspose Document.Compare feature.

In case helpful, my guess at what this bug is, is that Document.Compare fails to include inserted bookmarks in the resulting document. Thus, the bookmark that is internally referenced by the inserted cross-reference is missing form the document, resulting in the error.

@ssmolkin1,

We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system with ID WORDSNET-22550. We will further look into the details of this problem and will keep you updated here on the status of correction. We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-22550) have been fixed in this Aspose.Words for .NET 22.6 update also available on NuGet.