We are following the advice from this post https://www.docx4java.org/forums/docx-java-f6/inserting-page-break-in-docx-file-through-docx4j-t431.html to add a page break after an AltChunk section. But this only results in a line break instead of a page break (please see attached the generated file).
We are using docx4j 11.3.2
This is the code:
- Code: Select all
// add empty line
p = new P();
ObjectFactory factory = Context.getWmlObjectFactory();
Br br = factory.createBr();
p.getContent().add(br);
wordMLPackage.getMainDocumentPart().getContents().getContent().add(addPoint + 1, p);
// Docu Text from Server
wordMLPackage.getMainDocumentPart().addAltChunk(AltChunkType.Xhtml, docuText.getBytes(), addPoint + 2);
// Add page break. See https://www.docx4java.org/forums/docx-java-f6/inserting-page-break-in-docx-file-through-docx4j-t431.html
Br pageBreak = factory.createBr();
pageBreak.setType(STBrType.PAGE);
P para = factory.createP();
para.getContent().add(pageBreak);
wordMLPackage.getMainDocumentPart().getContents().getContent().add(addPoint + 3, para);
Do you have any idea what is going wrong?
Thanks, Klaus