For a general overview, have at look at section 2.10 (page 46) of
http://www.ecma-international.org/news/ ... Primer.pdfYou need to do 2 things really:
First, make sure you have a numbering definitions part which contains the numbering you want to use. The easiest way to do this is to use Word to save a docx containing the numbering you are after. (The NumberingRestart sample shows you how to create a numbering part from scratch)
Second, make sure that your heading definition (in styles.xml) includes a reference to the number you want to use. You could do that in Word as well, but if you want to do it via docx4j, fetch the content of the styles part:
- Code: Select all
Styles styles = wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart().getJaxbElement()
find the style of interest (ie your heading), then add something like the following to its w:pPr:
- Code: Select all
<w:numPr>
<w:numId w:val="1"/>
</w:numPr>