If you want to work with margins then you need to look at Sections, not at the HWPFDocument itself. There are problems here; firstly, that it is only possible (as far as I am aware) to get not set the margins dimensions and, secondly, that you may well have more than one section in a document. It has been a very long time since I did anything with sections so there will doubtless be problems but, nevertheless, you want to do something like this;
Open the document. Get the overall Range object from the document. On the overall range object, get the number of sections. Iterate through then and call the getSection(int) method on the overall range to get at the individual sections - remember that there could only be one. On the Section object that is returned you can read the marins dimensions but not set them. As far as I am aware - and do bear in mind that I could very well be wrong - it is not possible to set the margins widths using HWPF. Have you considered attempting to add this functionality into the API? It might be possible to look into the Sections class, discover where the information for the margins dimensions is read from and then work backwards to modify these values. If you do make it work, then please consider contributing the resulting work to the project. PS, one of the problems that I do remember is that section information will only be bound to the last paragraph in the section. -- View this message in context: http://apache-poi.1045710.n5.nabble.com/How-to-change-margins-of-a-word-document-tp5710067p5710101.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]
