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 5 at page no. 7 is missing. Here is the paragraph text, just to be more specific:

Als Dividende für das Geschäftsjahr 2020 werden bei der Muster Mandant AG 50 Mio. € (0,10 € pro Aktie) vorgeschlagen. Der verbleibende Bilanzgewinn von 256 Mio. € soll in die Gewinnrücklagen eingestellt werden.

This is a very critical issue for our application and would really appreciate if you can help us in this regard at your earliest. Thanks.

New-version.docx (93.1 KB)
Notes_IFRS–115-testing_IFRS Condensed Interim Financial Statements _ § 115 WpHG_2023_14-08-2023-15-13.docx (89.5 KB)

@omer.asalm Unfortunately, I cannot reproduce the problem on my side. I have used the following code for testing:

Document original = new Document(@"C:\Temp\original.docx");
Document changed = new Document(@"C:\Temp\changed.docx");

// Collect bookmakrs names from the original document.
List<string> originalBookmarkNames = new List<string>();
foreach (Bookmark bk in original.Range.Bookmarks)
    originalBookmarkNames.Add(bk.Name);

// Collect bookmakrs names from the changed document.
List<string> changedBookmarkNames = new List<string>();
foreach (Bookmark bk in changed.Range.Bookmarks)
    changedBookmarkNames.Add(bk.Name);

// Compare documents and save result
original.Compare(changed, "test", DateTime.Now);
original.Save(@"C:\Temp\out.docx");

// Open output document and check whether all bookmakrs are preserved after comparing.
Document doc = new Document(@"C:\Temp\out.docx");
foreach (string bkName in originalBookmarkNames)
{
    if (doc.Range.Bookmarks[bkName] == null)
        Console.WriteLine($"Bookmark {bkName} is missing.");
}
foreach (string bkName in changedBookmarkNames)
{
    if (doc.Range.Bookmarks[bkName] == null)
        Console.WriteLine($"Bookmark {bkName} is missing.");
}

Hi @alexey.noskov Thank you for your reply, even I don’t see this problemwhen I try to load these files from the file system. But in our product, we save the user uploaded docx files in S3 Storage and during the comparison we download the files from S3 Storage and load it as a stream and when I am doing that I see that there is no BookmarkStart and BookmarkEnd node for a paragraph. I am also attaching the screenshot of my debugging investigation as a reference. Looking forward to hear from you soon. Thanks

@omer.asalm There should not be any difference from where the document is loaded. Could you please load the file from S3 storage save to file system and them process it with Aspose.Words. Does the problem persist in such case? Is the required bookmark present in the document loaded from S3 and saved to disc (without processing it with Aspose.Words)?

Hi @alexey.noskov, When I load both version of files from S3 storage, while debugging, I can see that the Bookmarks are present in both files before the comparison, but after the comparison, bookmarks are getting lost for one paragraph. To double check this, I saved the document after the comparison to the file system and loaded it again as Word file from file system and for that file, the bookmarks are not present for the mentioned paragraph. I am attaching the file in the reply for your reference.

comparison.docx (73.5 KB)

@omer.asalm Unfortunately, I cannot reproduce the problem on my side using the documents you have provided earlier. Also, I have noticed the comparison result you have shared and the result produced on my side are quite different. Could you please make sure the files attached in the initial topic are correct?
Also, could you please create a simple console application that will allow us to reproduce the problem?

Hi @alexey.noskov, but the document that I provided last time “comparison.docx”, you can reproduce the error with this document.

@omer.asalm The provided comparison.docx document is the output document produced by Aspose.Words. I need the input documents and code to reproduce the problematic output on my side. So if possible please create a simple console application that included all required resources that will allow us to reproduce the problem on our side.