Playing around a little, I did find out something more. The margins are
measured in twips and there are constants defined to make it easier to work
with them. 

Add this line to the code

import org.apache.poi.hwpf.converter.AbstractWordUtils;

and then you can set the margin something like this;

sectProps.setDxaLeft((int)(1.5 * AbstractWordUtils.TWIPS_PER_INCH));

This will create a left margin that is one and a half inches wide.

Still though I am concerned about what might happen if the code is used
against a document that has two or more sections defined. It should be
possible to identify the range of paragraphs the sections 'contains' and
maybe that would allow someone to identify which section should be altered.
Of course, this might not be of import oin your case so feel free to ignore
my ramblings.

Yours

Mark B

PS If you use an IDE like NetBeans or Eclipse, then it should pop up a list
of the method names defined on the object in question. I am going to guess
that the methods needed to alter the sizes of the other margins will be
called something like setDxaRight, setDxaTop, setDxaBottom and you can
simply look through the pop up fior them.

--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/How-to-change-margins-of-a-word-document-tp5710067p5710116.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to