I tried the code here: How to set page orientation for Word document? but I can't set the page.
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
I am using apache poi 3.17, I added all the libraries, where could be the problem? Please help. Thank you!