This project is read-only.

Is there way to set margin for the doc?

May 7, 2010 at 9:13 AM


Is it possible to set a margin (both left and right side) for the generated word document?




May 7, 2010 at 9:27 AM

Yes it is.

When creating a section you can specify the margins like this:

$style = array('marginLeft'=>600, 'marginRight'=>600, 'marginTop'=>600, 'marginBottom'=>600);
$section = $PHPWord->createSection($style);




May 7, 2010 at 9:28 AM
Edited May 7, 2010 at 9:31 AM

Margins are set using the setMarginLeft(), setMarginRight(), setMarginBottom() and setMarginTop() methods of the section settings object.

// New Word Document 
$PHPWord = new PHPWord(); 

// New section 
$section = $PHPWord->createSection(); 

$section->addText("T'was Brillig, and the Slithey Toves did gyre and gimble in the wabe.");
May 7, 2010 at 9:30 AM
Hi, Thanks for the reply. Missed that part in the example. Regards Swarnendu