Reputation: 23
I'm attempting to create some templates in PHPWord. With the header and footer I would like to have two phrases on the left and right for each. However, using the code below gives an unnecessary line break. Any advice?
$footer = $section->addFooter();
$footer->addPreserveText(htmlspecialchars('Page {PAGE}', ENT_COMPAT, 'UTF-8'), null, array('alignment' => 'left'));
$footer->addText('Document', null, array('alignment' => 'right'));
Thanks
Upvotes: 1
Views: 1304
Reputation: 2710
You can use a table to get your data to the same line in your footer (/header):
$table = $footer->addTable(array('width' => '5000', 'unit' => 'pct'));
$table->addRow();
$table->addCell(2000)->addPreserveText(htmlspecialchars('Page {PAGE}', ENT_COMPAT, 'UTF-8'));
$table->addCell(2000)->addTextRun(array('align' => 'right'))->addText('Document');
Upvotes: 2