我需要在每个字页上设置边框,例如段落:
XWPFParagraph paragraph = document.createParagraph();
//Set bottom border to paragraph
paragraph.setBorderBottom(Borders.BASIC_BLACK_DASHES);
//Set left border to paragraph
paragraph.setBorderLeft(Borders.BASIC_BLACK_DASHES);
//Set right border to paragraph
paragraph.setBorderRight(Borders.BASIC_BLACK_DASHES);
//Set top border to paragraph
paragraph.setBorderTop(Borders.BASIC_BLACK_DASHES);
我找到了如何定义页边距大小,但它没有帮我设置边框:
CTSectPr sectPr = document.getDocument().getBody().addNewSectPr();
CTPageMar pageMar = sectPr.addNewPgMar();
pageMar.setLeft(BigInteger.valueOf(720L));
pageMar.setTop(BigInteger.valueOf(360L));
pageMar.setRight(BigInteger.valueOf(720L));
pageMar.setBottom(BigInteger.valueOf(360L));
答案 0 :(得分:0)
可以创建一组定义了底部边框的段落。如果所有段落都有相同的缩进(可以合理地假设),则会在页面底部生成边框。
这与我所定义的行为不一致;所以,遗憾的是,我并没有保存这份副本作为参考。我分享了这个,希望它可以帮助你找到一个起点。