Forum


Replies: 7   Views: 985
Add pagination and contents to the footers replacing them in an existing docx
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 admin  · 23-12-2021 - 15:11

Hello,

addHeader and addFooter methods only work with a single section. For this reason, the mergeDocx method available in Advanced and Premium licenses is needed to generate documents with multiple sections with different headers and footers (https://www.phpdocx.com/documentation/cookbook/headers-and-footers-for-sections).

If you need to overwrite headers or footers in a DOCX that contains one section, please note you may need to set all scopes (not only the default scope):

$docx->addFooter(array('default' => $numbering, 'first' => $numbering, 'even' => $numbering));

If you need to overwrite headers or footers in a DOCX that contains one or more sections, you can use the importHeadersAndFooters method (importing a DOCX that also includes all scopes of the headers/footers to be added: default, first, even):

$docx->importHeadersAndFooters('docx_footer.docx');

Regards.