If you create a WordprocessingMLPackage using the method WordprocessingMLPackage.createPackage, it will do:
- Code: Select all
// Create a styles part
Part stylesPart = new org.docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart();
try {
((org.docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart) stylesPart)
.unmarshalDefaultStyles();
which uses the styles defined in org/docx4j/openpackaging/parts/WordprocessingML/styles.xml. This is a relatively small set of styles, but does include Headings1-4.
There is another set of styles "org/docx4j/openpackaging/parts/WordprocessingML/KnownStyles.xml", which docx4j can use on demand via PropertyResolver.activateStyle. MainDocumentPart's createStyledParagraphOfText will use one of those styles if specified.
One enhancement which suggests itself would be to allow these 2 files to be overridden in the properties file, so you're not stuck which English language names and my choice of styles.