API Documentation
Word content
Format conversion
CryptoPHPDOCX
Digital Signature package
importHeadersAndFooters
Imports headers and footers from an external Word document.
PRO, PRO+ and CORPORATE PHPDocX >= 2.5
Description
public importHeadersAndFooters (string $path [, string $type])
This method allows for the insertion of Headers and Footers from an external Word document in the current Word document.
If the type parameter is ommited both headers and footers are imported.
Parameters
path
The path to the external Word document.
type
The options are:
- ‘headerAndFooter’ to import both header and footer (default value),
- ‘header’ for just the header or
- ‘footer’ for just the footer.
Return values
Void.
Code samples
Example #1: imports the header and footer from an existing Word document
require_once '../../classes/CreateDocx.inc';
$docx = new CreateDocx();
$docx->importHeadersAndFooters('TemplateHeaderAndFooter.docx');
$docx->addText('This is the resulting word document with imported header and footer');
//You may import only the header with
//$docx->importHeadersAndFooters('TemplateHeaderAndFooter.docx', 'header');
//and only the footer with
//$docx->importHeadersAndFooters('TemplateHeaderAndFooter.docx', 'footer');
$docx->createDocx('example_import_header_and_footer');
The resulting Word document looks like (download .docx file):
Change log
- Available since 2.5
Available examples
PHPDocx. Dinamic generation of reports in .docx format 


