Getting ordered collection of bookmarks

Hi,

I wanted to inquire whether the bookmark collection created from the document range is ordered - i.e, I wanted to know if the bookmarks in the collection are ordered according to the position they appear in the word document.

for(Bookmark b: doc.getRange.getBookmarks()){
    System.out.println(b.getName());
}

Hi Praneeth,

Thanks for your inquiry. Yes, Range.getBookmarks method returns a bookmarks collection that represents all bookmarks in the range. The bookmarks in the collection are ordered same as they appear in Word document and Aspose.Words DOM. Please read the following articles for more information on DOM:
https://docs.aspose.com/words/java/aspose-words-document-object-model/
https://docs.aspose.com/words/java/logical-levels-of-nodes-in-a-document/

Please let us know if you have any more queries.

Hey Tahir,
Thank you for confirming this. I hadn’t seen this as part of the javadocs for BookmarkCollection so I just wanted to make sure.

Hi Praneeth,

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.