Do you want live notifications when people reply to your posts? Enable Notifications Aspose Word - Bookmarks missing for paragraphs from the document after comparison

Hi,
We are a licenced Aspose User and we are using Aspose Words to compare word documents using Document.Compare method. We have noticed that for Aspose Words, when we try to compare two nearly same documents then the document that we get, from the Document.Compare method, has missing Bookmark node for some paragraphs, due to which our functionality breaks, as we generate IDs for the paragraph blobs from Bookmark ID. The version that we are currently using for Aspose Word is 23.8.0.
I have verified that the bookmarks are there when I try to parse the parse paragraphs without any document comparison, it only seems to be the case when we compare documents. I have also attached the word files for your reference. After the comparison, the bookmark for the paragraph 1 at page no. 1 is missing. Here is the paragraph text, just to be more specific:

Der Konzernabschluss der [ ORG ] wurde für das zum 31. [ DATE ] abgeschlossene [ DATE ] erstellt und umfasst die [ ORG ] (nachfolgend auch [ ORG ] oder [ ORG ]) und ihre Tochtergesellschaften sowie gemeinschaftliche Tätigkeiten (gemeinsam die „[ ORG ] [ ORG ]“ oder „[ ORG ]“) und assoziierte Unternehmen.

This is a very critical issue for our application and would really appreciate if you can help us in this regard at your earliest. Here is the sample code to reproduce the problem. Thanks.

var v1 = Path.Join("TestFiles/KV-2023.docx");
var document1 = new Document(v1);
var comments = document1.GetChildNodes(NodeType.Comment, true);
comments.Clear();
document1.Revisions.AcceptAll();
document1.RemoveMacros();


var v2 = Path.Join("TestFiles/KV-2024.docx");
var document2 = new Document(v2);
comments = document2.GetChildNodes(NodeType.Comment, true);
comments.Clear();
document2.Revisions.AcceptAll();
document2.RemoveMacros();

var doc = document1;

var author = Guid.NewGuid().ToString();
doc.Compare(document2, author, DateTime.Now);

var revisions = doc.Revisions;
revisions
    .Where(rev => rev.RevisionType == RevisionType.FormatChange || rev.RevisionType == RevisionType.StyleDefinitionChange)
    .ToList()
    .ForEach(rev => rev.Accept());


document1.LayoutOptions.CommentDisplayMode = CommentDisplayMode.Hide;

var revisionOptions = document1.LayoutOptions.RevisionOptions;
revisionOptions.ShowInBalloons = ShowInBalloons.None;
revisionOptions.ShowRevisionMarks = false;
revisionOptions.ShowRevisionBars = false;
revisionOptions.ShowOriginalRevision = false;

var docxStream = new MemoryStream();
document1.Save(docxStream, SaveFormat.Docx);

var newDoc = new Document(docxStream);

foreach (var node in newDoc.Document.GetChildNodes(NodeType.Any, true))
{
    if (node.NodeType == NodeType.Paragraph)
    {
        if (node.ParentNode.NodeType == NodeType.Comment)
            continue;

        var paragraph = (Paragraph)node;
        if (!paragraph.HasChildNodes)
            continue;
        var blobId = GetBlobId(paragraph);
        if (blobId == null)
        {
            Console.WriteLine("Not Found!");
        }
    }
}

KV-2023.docx (4.3 MB)

KV-2024.docx (4.7 MB)

@omer.asalm Looks like this is the same problem as you described in another your topic:
https://forum.aspose.com/t/288524

Hi @alexey.noskov yes it is more or less the same topic and we get these issues time to time with different files. Here we are facing again the bookmark issues, as per my investigation, after the comparison the bookmarks are totally gone for some paragraphs. Can you please also investigate on your side and provide some solution for this?

@omer.asalm I do not see any files attached. But I suspect the problem is the same as described in the above mentioned topic, i.e. there are bookmarks with duplicated names, that is not allowed. So the duplicated bookmarks are removed.

@alexey.noskov sorry, I just attached them to the main post. Please have a look.

@omer.asalm Thank you for additional information. As I suspected there are bookmarks with the same names in your documents. After comparing the duplicated bookmarks are removed from the resulting document, since it is not allowed to have several bookmarks in the document.