Binary Equality

I would like to do a binary comparison between two documents.

As mentioned in this post:

https://forum.aspose.com/t/pdf-differs-after-every-conversion-from-text-to-pdf/253739

Aspose is creating a unique identifier for each document and looks to be using a timestamp.

Is there a way to stop Aspose from doing this so a binary comparison can work?

@faith113 I am afraid there is no way to force Aspose.Words to use the same identifiers upon generation document. This is by design.

Is there any other way to compare documents which would provide a 100% reliable solution for equality testing? Looking at the Document’s compare method documentation it mentions some limitations. Also, there is no mention of how it would handle embedded OLE changes.

“The term “equal” documents mean that the comparison method is not able to represent changes as revisions. This means that both document text and text formatting are the same. But there can be other differences between documents. For example, Microsoft Word supports only format revisions for styles, and you cannot represent style insertion/deletion. So documents can have a different set of styles, and the Compare method still produces no revisions.”

https://docs.aspose.com/words/java/compare-documents/

@faith113 Unfortunately, as I have mentioned, there is no way to produce binary equal documents. Though, internally for testing purpose we use the approach you have described, i.e. disable random id generation upon producing the documents, so the produced document can be compared with etalon documents. But, I am afraid there is no way to achieve this using public release version of Aspose.Words.
The only way that can be suggested, in case of DOCX documents, is unzipping the document, replacing randomly generated IDs with some constant value or removing them in XML files and them comparing XML files. The documents will be damaged such way, but the approach will give an ability to compare the document equality.

Understood, thank you for your detailed reply.

1 Like