We are to rename the bookmark in the word document. Our logic right now deletes the old definition and adding new bookmark at the same position. While deleting we don’t want to loose the old bookmark outline level (since we are using bookmark levels while generating (PDFs). Not seeing any access-er for outline level of bookmark. Could you please help us? Thanks for looking into this.
Document doc = new Document(getMyDir() + “Bookmark.doc”);
// Use the indexer of the Bookmarks collection to obtain the desired bookmark.
Bookmark bookmark = doc.getRange().getBookmarks().get(“MyBookmark”);
// Get the name and text of the bookmark.
String name = bookmark.getName();
String text = bookmark.getText();
// Set the name and text of the bookmark.
bookmark.setText(“This is a new bookmarked text.”);
This way is losing bookmarks when they are nested and overlapping. In the case, say text is “text here”, and bookmark1 lies [text], bookmark2 [te] (the part of same text), and the bookmark3 lies in [xt he], then after doing renaming of bookmark1 and 2, seeing that in output document only bookmark present is bookmark1 and all else are lost. Please look into this. Thanks.