Is there way to set margin for the doc?

May 7, 2010 at 8:13 AM

Hi,

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

 

regards,

Swarnendu

Coordinator
May 7, 2010 at 8: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);

 

regards

raw

Developer
May 7, 2010 at 8:28 AM
Edited May 7, 2010 at 8: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->getSettings()->setMarginLeft(1200); 
$section->getSettings()->setMarginRight(1200); 

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