我需要创建一个简单的 Word 文档用于从 java 程序打印。有必要将输出打印在单独的页面上。我正在使用以下代码:
XWPFDocument document = new XWPFDocument();
XWPFParagraph paragraph = document.createParagraph();
XWPFRun run = paragraph.createRun();
run.setText("TITLE");
run.addCarriageReturn();
run.setText("some text and stuff here");
run.addBreak(BreakType.PAGE);
run.setText("more text");
run.addCarriageReturn();
run.setText("one more line");
问题是,我尝试在此分页符之后插入的任何内容都会单独出现在页面上(上例中的最后两行文本将出现在不同的页面上)。就好像现在每个语句后面都有一个“自动分页符”。
我尝试过使用新运行或新段落,但结果始终相同。有任何想法吗?在这里开始变得非常沮丧......
XWPFDocument document = new XWPFDocument();
...
XWPFParagraph paragraph = document.createParagraph();
paragraph.setPageBreak(true);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)