Package org.docx4j.samples
Class TocIntoSdtDemo
java.lang.Object
org.docx4j.samples.TocIntoSdtDemo
Modern versions of Word typically insert a ToC within an SDT (aka content control).
For example:
<w:sdt>
<w:sdtPr>
<w:docPartObj>
<w:docPartGallery w:val="Table of Contents"/>
This was not the case for now-ancient versions of Word.
And nor is it the case for a table of figures even now. For example:
<w:p>
<w:fldSimple w:instr=" TOC \h \z \c "Figure" ">
or
<w:r>
<w:fldChar w:fldCharType="begin"/>
</w:r>
<w:r>
<w:instrText xml:space="preserve"> TOC \h \z \c "Figure" </w:instrText>
</w:r>
<w:r>
<w:fldChar w:fldCharType="separate"/>
:
The purpose of this class is to find a "bare" TOC and wrap it in a content control.
Once this has been done, you can use TocGenerator's updateToc method on it.
-
Field Details
-
log
private static org.slf4j.Logger log -
inputfilepath
-
outputfilepath
-
-
Constructor Details
-
TocIntoSdtDemo
public TocIntoSdtDemo()
-
-
Method Details
-
main
- Throws:
Exception
-