I'm able to add page numbers to a docx file with this technique, but I don't know how to get the page numbers to start with a particular number (e.g., I want the first page to say "5").
I've tried using CTPageNumber, but the following didn't add anything to the document:
static void addPageNumbers(XWPFDocument doc, int startingNum) {
CTSectPr sectPr = doc.getDocument().getBody().isSetSectPr() ? doc.getDocument().getBody().getSectPr()
: doc.getDocument().getBody().addNewSectPr();
CTPageNumber pgNum = sectPr.isSetPgNumType() ? sectPr.getPgNumType() : sectPr.addNewPgNumType();
pgNum.setStart(BigInteger.valueOf(startingNum));
pgNum.setFmt(STNumberFormat.DECIMAL);
}