Bookmarks not found

I have a bookmark which surrounds text and is situated within the cell of a table. Aspose does not find this bookmark. I want to conditionally delete the text by removing the bookmark.

I attach the Word document. You will see that the bookmarks ‘first’ and ‘second’ are not found. ‘Third’, an I Bar within another table cell is found and ‘Fourth’ which surrounds text but is outside the table, is also found.

Hi,

Thank you for reporting the issue to us. I have logged this as defect #3140. The developer responsible for the WordML format is currently on leave but I think he will address this issue shortly once he’s back.

Could I add another scenario where a bookmark, the first item within a table cell, followed by another bookmark creates a situation where the second bookmark is not found? Adding a space before the first bookmark alllows both bookmarks to be seen.

Sure, please attach the corresponding document as well.

I attach an example file. There are four bookmarks present. One is not found. Looking at the xml, I can see that this problem occurs when an I bar bookmark appears as a sibling rather than child of a element and the following contains a bookmark.

When the same file is saved as a ‘doc’, there is no problem in discovering all bookmarks.

Thank you for the issue. We consider it is a defect of the WML subsystem. Registered as #3145.

These are “known issues” and not going to be fixed immediately.

Microsoft Word is way too flexible in allowing bookmark start and end at any position in the document. Aspose.Words is not yet that flexible.

In the first example, First Bookmark is a problem because although it visually starts and ends within a single paragraph in one cell, Microsoft Word places the bookmark start BEFORE the first cell in WordML and then places the bookmark end inside the paragraph inside the cell. This creates “jagged” bookmark from Aspose.Words point of view. Such “jagged” bookmarks (where start of bookmark is at the different level in the document tree from the bookmark end) are not yet supported in Aspose.Words.

- bookmark start

- bookmark end

As you can see in the above example bookmark start and end are at the different depth in the XML tree. Aspose.Words does not support that.

Another limitation of Aspose.Words regarding bookmark is that the bookmarks must have the same parent or grandparent node.

For example, when a bookmark starts and ends in the same paragraph (the paragraph node is the parent), this is supported. Also, when a bookmark starts in one paragraph and ends in another paragraph, it is also supported (the grandparent node is the section that contains the paragraphs). But if a bookmark starts in one section and ends in another, this is not yet supported in Aspose.Words.

We plan to improve bookmarks in Aspose.Words in the future to support the above two limitations, but cannot give an estimate at this stage.

Regarding the second issue 1345:

In this case, Microsoft Word outputs the bookmark in question before the cell.

while all other bookmarks are inside paragraphs.

Aspose.Words supports bookmark start and end in WordML that are inside paragraphs only at the moment.

We will try to fix, but no dates yet.

Hi,

We have released Aspose.Words 4.3.0:

https://downloads.aspose.com/words/net

3145- Bookmark is lost when loading WordML document.

3140 - Bookmarks placed in a table cell not found.