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.
[code]
$info[0] = array('key1'=>'value1','key2'=>'value2',.....);
$info[1] = array('key1'=>'value1','key2'=>'value2',.....);
...
$info[n]..;
$docx = new CreateDocx();
$docx->addTemplate('/tmp/template.docx');
for($i=0;$i<$num_pages;$i++){
// $docx->addTemplate('/tmp/template.docx');
print "<pre>";
print_r($docx->getTemplateVariables());
print "</pre>";
foreach ($info[$i] as $key => $value) {
$docx->addTemplateVariable($key,"{$value}");
}
$filename="/tmp/tmp-{$i}";
$docx->createdocx($filename);
$docx->mergeDOCX($filename.".docx",'/tmp/template.docx');
}
[/code]
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
/Peter