We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Comparison of .docx does not work

Hi guys. When I am trying to compare two word documents as described below, I am getting revisions (documents are not the same) after comparison, even second document is just a copy of first one.

Please advice what I am doing incorrectly in this case?

Aspose.Words.Document docA = new(@"C:\temp\Doc.docx");
Aspose.Words.Document docB = new(@"C:\temp\DocCopy.docx");

// There should be no revisions before comparison.
docA.AcceptAllRevisions();
docB.AcceptAllRevisions();

docA.Compare(docB, "m", DateTime.Now);
docA.Save(@"C:\temp\Doc_Aspose_word_report.pdf");

docA.Revisions // here I am getting 8 revision objects

Some of the revisions:

  Aspose.Words.Revision
    {
        Author = "m", 
        DateTime = <2023-01-05 12:28:53.3391943>, 
        Group = 
        Aspose.Words.RevisionGroup
        {
            Author = "m", 
            RevisionType = RevisionType.Insertion {value: 0}, 
            Text = ""
        }, 
        ParentNode = {empty}, 
        ParentStyle = "[Member 'ParentStyle' threw an exception: 'Can not access ParentStyle for a node revision. Use ParentNode instead.']", 
        RevisionType = RevisionType.Insertion {value: 0}
    }, 
    Aspose.Words.Revision
    {
        Author = "m", 
        DateTime = <2023-01-05 12:28:53.3391943>, 
        Group = 
        Aspose.Words.RevisionGroup
        {
            Author = "m", 
            RevisionType = RevisionType.Deletion {value: 1}, 
            Text = ""
        }, 
        ParentNode = {empty}, 
        ParentStyle = "[Member 'ParentStyle' threw an exception: 'Can not access ParentStyle for a node revision. Use ParentNode instead.']", 
        RevisionType = RevisionType.Deletion {value: 1}
    }, 
    Aspose.Words.Revision
    {
        Author = "m", 
        DateTime = <2023-01-05 12:28:53.3391943>, 
        Group = 
        Aspose.Words.RevisionGroup
        {
            Author = "m", 
            RevisionType = RevisionType.Insertion {value: 0}, 
            Text = ""
        }, 
        ParentNode = {empty}, 
        ParentStyle = "[Member 'ParentStyle' threw an exception: 'Can not access ParentStyle for a node revision. Use ParentNode instead.']", 
        RevisionType = RevisionType.Insertion {value: 0}
    },

@usernamename Could you please attach your documents here for testing? We will check the issue and provide you more information.

Hi Alexey,

Thanks for quick response. I am not able to attach those documents as they may have sensitive information in them, sorry. But I am just making copy of one of them and trying to compare them.

Could it be related to exception I am getting in some of my revisions, below?
As when I am trying to compare same document to itself:

Aspose.Words.Document docA = new(@"C:\temp\Doc.docx");
Aspose.Words.Document docB = new(@"C:\temp\Doc.docx");

I am getting revision count more than 0.

@usernamename Unfortunately, it is impossible to tell you what the problem is without your documents. Have you tried comparing the documents using MS Word? Does it show any difference?