I am trying to create a document and want to use different styles for my headings so I can easily generate a table of contents in the end.
Using following code, I try to generate a paragraph, using the "Heading1" style.
- Code: Select all
P paragraph = parent.getMainDocumentPart().addParagraphOfText( text );
PPr paragraphProperties = objFactory.createPPr();
PStyle pStyle = new PStyle();
pStyle.setVal( style.getStyle().getStyleId() );
paragraphProperties.setPStyle( pStyle );
paragraph.setPPr( paragraphProperties );
This adds the paragraph and the text to my ...