我想添加目录(Toc)在文档的第3页使用apache XWPF。
Here is the code below :
XWPFDocument doc = new XWPFDocument();
CTSdtBlock block = doc.getDocument().getBody().addNewSdt();
TOC toc = new TOC(block);
toc.addRow(3, "toc", 3, "16283778");
doc.write(new FileOutputStream(new File("toc.docx")));发布于 2017-10-23 17:46:06
我认为您应该使用run在文档中创建一个paragraph。这样你就可以在你的paragraphs中添加BreakType.PAGE了。
XWPFParagraph paragraph = document.createParagraph();
XWPFRun run = paragraph.createRun();
run.addBreak(BreakType.PAGE);BreakType.PAGE跳过一页
https://stackoverflow.com/questions/46884439
复制相似问题