But when I open the document after I ran the program, the table of contents is empty, but the navigation panel does include some of the headers I specified. So i started off by create the document from a template: XWPFParagraph document Control Heading = doc.create Paragraph(); document Control Page Break(true); document Control Alignment(Paragraph Alignment. Is there any way I can specify where the TOC should be generated?
The enforce Update Fields() did work for the TOC, but it only updated it in the navigation panel, and not in the word document itself.
For instructions on the basics of inserting a TOC, see Word MVP Shauna Kellys article How to create a table of contents in Microsoft Word.
If you have never used a TOC before, I highly recommend that you read Shaunas article before reading this one.
If you want to use a different paragraph style as a table of contents entry, select the Additional Styles check box in the Create from area, and then click the Assign styles button next to the check box.
I cannot read past the end of the 13th chapter and page 313 (acts like it is the end of the book).
I deleted the old ebook and loaded the new on the ipad but it still has the 13 chapters and 313 pages for the ebook.
I have to create a table of contents at the start of the method and then I update it at the end to get all the new headers.
Currently I use doc.create TOC(), where doc is a variable created from XWPFDocument, to create the table at the start and then I use doc.enforce Update Fields() to update everything at the end of the document. It works but the TOC is now at the end of the document.