Free Support Forum - aspose.com

Unexpected Bookmarkend nodes found directly under body

BookmarkEnd nodes are displayed at the same level as paragraph node if the bookmark contains empty new lines.
Issue found on Aspose Words 18.10.0.0 it does not reproduce using version 18.8.0.0
BookmarkStart nodes are displayed as children of paragraph nodes as in previous versions.
I’ve created a sampleTest6.zip (9.0 KB) document and some demo code to reproduce the issue:

               Document doc = new Document("C:\\_Test\\Test6.docx");        
               Body body = doc.FirstSection.Body; 
               List<NodeType> Types = new List<NodeType>();
               var next = body.FirstChild;
               while (next != null)
               {
                Types.Add(next.NodeType);
                next = next.NextSibling;
               }

Please confirm if this is a bug on the new Aspose Words version.

@adrian.anton

Thanks for your inquiry. The bookmark nodes are allowed to be placed on the block, cell and row levels in the latest version of Aspose.Words for .NET 18.10. We suggest the you please read the following article.
Working with Bookmark on Block, Cell, Row Levels

Thank you for the response Tahir,

Our concern regarding the BookmarkEnd nodes that now appear at the same level with Paragraph nodes in this specific scenario is that their corresponding BookmarkStart are not on the same level.
We can work-around the issue on our side by ignoring BookmarkEnd notes but I need confirmation that, for this specific scenario, the presence of the BookmarkEnd nodes at that level is expected.

@adrian.anton

Thanks for your inquiry. Yes, it is possible that BookmarkEnd node exists at block level.

If you want to open a document in the inline-bookmarks mode, please set the value of LoadOptions.AnnotationsAtBlockLevel property as false .

Thank you Tahir,

We’ll look into using the AnnotationsAtBlockLevel.
Just to clarify, the fact that the BookmarkStart and BookmarkEnd nodes are at different levels in this scenario is expected?

@adrian.anton

Thanks for your inquiry. Yes, the BookmarkStart and BookmarkEnd nodes can exist at different levels in the Aspose.Words’ DOM.

@tahir.manzoor

Thanks for re-confirming Tahir.
We’ve tried using the AnnotationsAtBlockLevel and it warns us that this setting may become obsolete in future versions.
Is it going to be replaced with another setting already in the product? Perhaps we can use the new setting directly.

@adrian.anton

Thanks for your inquiry. In the previous versions bookmarks were moved into the next nearest paragraph on document loading. So, the bookmarks at Block, Cell, Row levels were imported incorrectly. Due to this incorrect behavior, the property LoadOptions.AnnotationsAtBlockLevel will be obsolete in future. If your document has block level bookmarks, please modify your code accordingly. We suggest you please read API changes about block level bookmarks from here:
Aspose.Words for .NET 18.9 Release Notes