Update Table of Content of docx document in word using docx4
Posted: Wed Sep 29, 2021 5:15 pm
I want to update TOC in my docx document. One way is generate the table entries, and the corresponding page numbers. Now I can generate the table entries and show it in TOC. But the problem is there aren't right corresponding page numbers. So I need to write proper pageRef for every headings. There are some ways:
1) Use export document to PDF and define number of pages. You can use docx4j TOC Helper. But it need to use special converter, because plutext is died now. Maybe docx4j-export-FO now work fine. Disadvantages - spend time for converting and there is a probability of unproper page numbers.
2) Update TOC during opening the document. There are two ways to do so:
2.1) Use macros. Disadvantages - need to change security level.
2.2) Write <w:updateFields w:val="true" /> in setting.xml file of WordProcessingML. Disadvantages - special warning boxes for updating.
Is there other way to achieve my goal?
1) Use export document to PDF and define number of pages. You can use docx4j TOC Helper. But it need to use special converter, because plutext is died now. Maybe docx4j-export-FO now work fine. Disadvantages - spend time for converting and there is a probability of unproper page numbers.
2) Update TOC during opening the document. There are two ways to do so:
2.1) Use macros. Disadvantages - need to change security level.
2.2) Write <w:updateFields w:val="true" /> in setting.xml file of WordProcessingML. Disadvantages - special warning boxes for updating.
Is there other way to achieve my goal?