1

Sometimes, when defining a bookmark in a .docx file (using Word 2016 in this case), the bookmark start tag (<w:bookmarkStart>) is placed by MS Word before the start of the paragraph. Unzipping the .docx file reveals the following:

<w:bookmarkStart w:id="38" w:name="MyBookmark"/><w:p w14:paraId="1B2F3A46" ...>...
<w:bookmarkEnd w:id="38"/></w:p>

Such a bookmark is not listed by iterating in any of the paragraphs bookmarkStart elements, so that the following code will not list this bookmark:

XWPFDocument document = ...
for (XWPFParagraph paragraph : document.getParagraphs())
{
    for(CTBookmark bookmark : paragraph.getCTP().getBookmarkStartList())
        System.out.println(bookmark.getName());
    {
}

Question is how to discover that sort of bookmark that is placed outside of a paragraph?

andrewJames
  • 19,570
  • 8
  • 19
  • 51
Markus Pscheidt
  • 6,853
  • 5
  • 55
  • 76
  • 1
    Get the bookmark lists from document's body? `XWPFDocument document ...; ... document.getDocument().getBody().getBookmarkStartList() ...`. – Axel Richter Oct 01 '20 at 06:33

0 Answers0