Set margins with Apache poi

apache-poi, java, margins, ms-word

Solution

Thanks to Gagravarr for pointing me in the right direction. Seems I didn't have the full ooxml-schemas-1.1.jar. This code now sets the margins perfectly

 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));

Not sure what the units are, but 720 corresponds to half an inch!

Problem

Using Apache poi to create a basic word document, I need to change the page margins. The answer to this question seems perfect, but I don't have the CTPageMar class. I'm using 3.10. Anyone had any luck with this with different versions, or different methods?

Original source

Related problems