Forum


Replies: 3   Views: 1266
Section headers
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  · 10-06-2021 - 18:08

Hello,

UPDATE: phpdocx 14 includes addHeaderSection and addFooterSection to accomplish this task. https://www.phpdocx.com/documentation/cookbook/headers-and-footers-for-sections

Are you generating the sections from scratch using phpdocx? Or do you need to add headers or footers to existing sections in a template?

If you are creating a DOCX with a single section using phpdocx you can use addHeader/addFotter methods setting default, even and first as array keys to insert each header/footer target of that section.

If you are creating a DOCX with multiple sections with their own headers and footers, then you need to use mergeDocx. Please check the documentation available on https://www.phpdocx.com/documentation/cookbook/headers-and-footers-for-sections.

There's no method to add new headers or footers to sections in existing documents. Using the importHeadersAndFooters method you can overwrite headers and footers of all sections importing the headers and footers from an external document. If you want to modify headers and footers from a template, they must exist in the template, so they can be changed using template methods or DOCXPath; there's no method to generate and add a header or footer to a section in a template.

Regards.