Page 1 of 1

Update Table of Contents

PostPosted: Thu Oct 25, 2012 1:18 am
by gabell
Hi,

I have had a good look around but can't seem to find a way to programmatically update a table of contents. The only information I came across is to set a flag which forces an update on open, which does the job but due to the warning message it isn't as clean as I'd like. The documents I'm generating will be sent around to many people and I don't want to cause confusion with the warning message they'd be presented with. The code I'm using to do this is:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
DocumentSettingsPart dsp = template.getMainDocumentPart().getDocumentSettingsPart();
CTSettings objCTSettings = dsp.getJaxbElement();
BooleanDefaultTrue b = new BooleanDefaultTrue();
b.setVal(true);
objCTSettings.setUpdateFields(b);
dsp.setJaxbElement(objCTSettings);
template.getMainDocumentPart().addTargetPart(dsp);
 
Parsed in 0.015 seconds, using GeSHi 1.0.8.4


is there something else I can do?

cheers,
graham

Re: Update Table of Contents

PostPosted: Thu Oct 25, 2012 3:19 am
by jason
Not sure whether you've seen docx-java-f6/table-of-contents-t187.html#p2555

Please let us know whether the suggestions there help.

If not, we could bite the bullet and add code to docx4j which generates the TOC. A recent poster wanted to do this for PDF output: docx-java-f6/adding-toc-support-in-pdf-output-t1220.html