Forum


Replies: 2   Views: 425
Page-of generating output twice in footer as inline content
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by robbed  · 05-09-2023 - 21:40

I am trying to create a single line footer with text, two links, a date and a page number. Everything works fine when I use 'numbering' as the type parameter for the page numbers but when I try to use 'page-of' it generates the output twice.

Here is a simplified version of the code for my footer that still demonstrates the issue:

require_once 'classes/CreateDocx.php';

$docx = new CreateDocx();

$numbering = new WordFragment($docx);
$numbering->addPageNumber('page-of');

$ftr = array();
$ftr[] = array('text' => 'Generic footer text ');
$ftr[] = $numbering;

$footerWordFragment = new WordFragment($docx);

$footerWordFragment->addText($ftr);

$docx->addFooter(array('default' => $footerWordFragment));

$docx->addText('This is the first page.');
$docx->addBreak(array('type' => 'page'));
$docx->addText('This is the second page.');
$docx->addBreak(array('type' => 'page'));
$docx->addText('This is the third page.');

$docx->createDocx('output');