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

Free Support Forum - aspose.com

Docs comparison - accept revision not working

Hi,


I have a flow as described below:
  1. Generate a word doc using Aspose.Words plugin (lets call it docB).
  2. Modify the doc above (docB).
  3. Generate a new doc (similar to docB before the modifications) using Aspose.Words plugin (lets call it docA).
  4. Comapre those 2 docs using the code below:
    Aspose.Words.License license = new Aspose.Words.License();
    license.SetLicense(“Aspose.Words.lic”);

    docA = new Aspose.Words.Document(newFilePath);
    docB = new Aspose.Words.Document(editedFilePath);

    if (docB.HasRevisions)
    {
    docB.AcceptAllRevisions();
    }

    docA.Compare(docB, “user”, DateTime.Now);

    for (var index = 0; index < docA.Revisions.Count; index++)
    {
    switch (docA.Revisions[index].RevisionType)
    {
    case RevisionType.FormatChange:
    case RevisionType.StyleDefinitionChange:
    docA.Revisions[index].Accept();
    break;
    case RevisionType.Insertion:
    case RevisionType.Moving:
    case RevisionType.Deletion:
    break;
    default:
    break;
    }
    }

    docA.Save(newFilePath);

  5. Save the compared doc as docA.
My expectation is that all “FormatChanges” revisions will be accepted and once the user open the new file (docA) he will see only insertion, deletion and moving changes, to be more precise, I want to show the user only merge conflicts in the final doc (exclude FormatChange and StyleDefinitionChange).

But the “docA.Revisions[index].Accept();” method is not working as expected.
When I open the result doc The FormatChange revisions are still there and not accepted.

In this example I’ve added this text “(הוספה
ידנית)
” to docB and the revisions count is above 300.

Attached the relevant docs:
  • docB.docx - the modified doc.
  • docA.docx - the original doc.
  • docA_After compare.docx - the comparison result doc.
Thanks,
Leon Shmulevich
Hi Leon,

Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-14621. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi Tahir,

Are there any news regarding the issue?

Hi Leon,

Thanks for your inquiry. We try our best to deal with every customer request in a timely fashion, we unfortunately cannot guarantee a delivery date to every customer issue. Our developers work on issues on a first come, first served basis. We feel this is the fairest and most appropriate way to satisfy the needs of the majority of our customers.

Currently, your issue is pending for analysis and is in the queue. Once our product team completes the analysis of your issue, we will then be able to provide you an estimate.

Thanks for your patience and understanding.
Hi Leon,

Thanks for your patience. It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-14621) as 'Not a Bug'.

Document.Revisions is a live collection and is rebuilt each time document changed (accepting revision changes document as well). So, revisions cannot be accepted as you are doing in the code. Please use following code example to get the desired output.

Document docA = new Aspose.Words.Document(MyDir + "docA.docx");

Document docB = new Aspose.Words.Document(MyDir + "docB.docx");

if (docB.HasRevisions)

{

docB.AcceptAllRevisions();

}

docA.Compare(docB, "user", DateTime.Now);

ArrayList formatRevisions = new ArrayList();

for (int index = 0; index < docA.Revisions.Count; index++)

{

switch (docA.Revisions[index].RevisionType)

{

case RevisionType.FormatChange:

case RevisionType.StyleDefinitionChange:

// Collect all needed revisions.

formatRevisions.Add(docA.Revisions[index]);

break;

case RevisionType.Insertion:

case RevisionType.Moving:

case RevisionType.Deletion:

break;

default: break;

}

}

// Accept all collected revisions.

foreach (Revision revision in formatRevisions)

revision.Accept();

docA.Save(MyDir + "Out v16.12.0.docx");