Forum


Replies: 2   Views: 3038
How do i used addheader to add a blank header for letter headed paper to every page?
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  · 03-11-2016 - 08:47

Hello,

The easiest solution is to use the embedHTML method adding <br> tags:

<?php

require_once 'classes/CreateDocx.inc';

$docx = new CreateDocx();

$wf = new WordFragment($docx, 'defaultHeader');
$wf->embedHTML('<br><br><br><br>');

$docx->addHeader(array('default' => $wf));

$docx->addText('Document content');

$docx->createDocx('output');

Or you could use addBreak to add breaks in the WordFragment added to the header.

If the number of headers is limited, you could created empty DOCX templates with the headers and import them using the importHeadersAndFooters method. This method removes existing headers.

Regards.