Forum


Replies: 9   Views: 1229
Replacing variable inserts a footer on page 1 when not present in template
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  · 27-05-2021 - 21:35

Hello,

addHeader and addFooter methods remove existing headers and footers. These methods are available to be used when creating a DOCX from scratch, not with templates, because existing headers/footers are removed, and the new headers/footers are added only to the last section.

To add contents to headers/footers to a DOCX template you can use the following methods:

  • addHeaderSection and addFooterSection methods that include the removeOthers option to keep or remove existing headers and footers.
  • importHeadersAndFooters: the recommended way. You need to create a DOCX with the headers/footers to be imported and import them (default and first must be applied to addHeader)
  • add placeholders in headers and footers in the template and then use template methods to replace the placeholders by the new contents

Regards.