Bookmarks with duplicate name

I am using Aspose Words for Java 17.3.0. I have a docx document which has 2 bookmarks, which share the same name.
I bumped into issue with removal of these bookmarks. Looks like library is unable to identify BookmarkEnd elements for both bookmarks correctly. They both refer to single BookmarkEnd element, which is wrong. Exception is thrown, when I remove bookmarkEnd element of second bookmark as a result.

Exception in thread “main” java.lang.IllegalStateException: Cannot remove because there is no parent.
at com.aspose.words.Node.remove(Unknown Source)

Needless to say that this is causing problems to our customers.

Code snippet to reproduce this below (file attached):
final String inputFile = INPUT_FOLDER + “bookmark_problem.docx”;
License license = new License();
Document document = new Document(inputFile);
BookmarkCollection bookmarks = document.getRange().getBookmarks();
System.out.println("Amount of bookmarks: " + bookmarks.getCount());
BookmarkStart start1 = bookmarks.get(0).getBookmarkStart();
BookmarkStart start2 = bookmarks.get(1).getBookmarkStart();
BookmarkEnd end1 = bookmarks.get(0).getBookmarkEnd();
BookmarkEnd end2 = bookmarks.get(1).getBookmarkEnd();
System.out.println(“BookmarkEnd1:” + end1);
System.out.println(“BookmarkEnd2:” + end2);

    end2.remove(); (10.8 KB)

BTW your forum message editor is a total mess…
Didn’t manage to make code as preformatted text… it works in very weird way


Thanks for your inquiry. We have tested the scenario and noticed the reported issue. We have logged a ticket WORDSNET-15823 in our issue tracking system for further investigation and rectification. We will notify you as soon as it is resolved.

We are sorry for the inconvenience.


The issues you have found earlier (filed as WORDSNET-15823) have been fixed in this Aspose.Words for .NET 17.10 update and this Aspose.Words for Java 17.10 update.