Forum


Replies: 9   Views: 1031
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 removes existing headers and footers and add the new header/footer only to the last section of the document. 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:

  • 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.