/**
* 切换纸张方向 强行换页
* @param paragraph 需要切换的段落
* @param orientation landscape 竖向
*/
public static void changeOrientation(XWPFParagraph paragraph, String orientation) {
CTSectPr ctSectPr = paragraph.getCTP().addNewPPr().addNewSectPr();
CTPageSz pageSize = ctSectPr.isSetPgSz() ? ctSectPr.getPgSz() : ctSectPr.addNewPgSz();
if (orientation.equals("landscape")) {
pageSize.setOrient(STPageOrientation.LANDSCAPE);
pageSize.setW(BigInteger.valueOf(842 * 20));
pageSize.setH(BigInteger.valueOf(595 * 20));
} else {
pageSize.setOrient(STPageOrientation.PORTRAIT);
pageSize.setH(BigInteger.valueOf(842 * 20));
pageSize.setW(BigInteger.valueOf(595 * 20));
}
}
XWPFParagraph paragraph1 = document.createParagraph();
在页与页之间调用