News

Adding a section to a docx document with PHPDocX

  • Jun 06, 2011

This information is outdated, please, refer to the addSection documentation for up to date info.
Creating a section with PHPdocx is now very easy.
You may just use the code below with the obvious modifications to fit your particular needs:


require_once '../../classes/CreateDocx.inc';

$docx = new CreateDocx();

// The Text
$text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, ' .
'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ' .
'enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut' .
'aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit ' .
'in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ' .
'Excepteur sint occaecat cupidatat non proident, sunt in culpa qui ' .
'officia deserunt mollit anim id est laborum.';

$docx->addText($text);

// Text parameters
$paramsText = array(
'b' => 'single'
);

$docx->addText($text, $paramsText);

// Custom Section
$paramsSection = array(
'orient' => 'landscape',
'top' => 4000,
'bottom' => 4000,
'right' => 4000,
'left' => 4000
);
$docx->addSection($paramsSection);

$docx->addText($text);

$docx->addText($text, $paramsText);

$docx->createDocx('example_section');