我在这里尝试了代码:How to set page orientation for Word document?但我无法设置页面。
XWPFDocument doc = new XWPFDocument();
CTDocument1 document = doc.getDocument();
CTBody body = document.getBody();
if (!body.isSetSectPr()) {
body.addNewSectPr();
}
CTSectPr section = body.getSectPr();
if(!section.isSetPgSz()) {
section.addNewPgSz(); //in this part, the "addNewPgSz()" does not appear
}
CTPageSz pageSize = section.getPgSz(); //this part, the "CTPageSz" is not available
我正在使用apache poi 3.17,我添加了所有库,哪里可能是问题?请帮忙。谢谢!