Replies: 6   Views: 3559
Addtemplate to each 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 peter  · 11-04-2013 - 12:13


I was told by support (via an email) that there are examples on howto solve this problem and the only reasonable example I found was a merging of two templates so I began to try to find a way and came up with this solution:

My template has variables in both header and document.

$info[0] = array('key1'=>'value1','key2'=>'value2',.....);
$info[1] = array('key1'=>'value1','key2'=>'value2',.....);

$docx = new CreateDocx();

// $docx->addTemplate('/tmp/template.docx');
print "<pre>";
print "</pre>";
foreach ($info[$i] as $key => $value) {

The first printout of templatevariables shows an array containing both 'document' and 'header' variables
while the second and so on the printout only shows 'document' variables

The number of pages in the created document is correct, each page document variables are correctly replaced.
The header variables are only replaced on first page with correct values (the ones in $info[0]), on next page and so on it is still
the values in $info[0].

any suggestions or directing me to the example that handles this kind of case