Page 1 of 1

Update TOC on merged docx

PostPosted: Fri Oct 20, 2017 10:40 pm
by imaging
Hi,
I have merged several docx with the docx4j enterprise eval version library.
The first of them has the TOC already.
How can I open the merged docx file and update the TOC with the page numbers/section that now I have in the merged docx?

Thank you for help

Re: Update TOC on merged docx

PostPosted: Sat Oct 21, 2017 1:39 am
by jason
If the ToC is in a content control (so docx4j can find it), you ought to be able to use the ToC update code; see https://github.com/plutext/docx4j/blob/ ... eDemo.java

Re: Update TOC on merged docx

PostPosted: Mon Oct 23, 2017 8:26 pm
by imaging
Thank you Jason for your quick reply,
but I need further help to know how to use the content control to update the TOC.
I create a new word docx document as template with a content control on the first page.
Inside it I put the TOC that I need to update after the merge of several docx.
In the example that you set, there are no references to the content control.
Could you give me some examples code?

Thank you again

Re: Update TOC on merged docx

PostPosted: Wed Jun 09, 2021 10:22 pm
by JenniferFrankel
I create a new word Docx document as a template with content control on the first page. Inside it, I put the https://chinesebuffetnearmenow.net/fast-food-near-me/ TOC that I need to update after the merge of several docx. In the example that you set, there are no references to the content control.