Hello,
I'm actually using phpdocx 4.1 (Corp. license) and I've got a strange problem while using importHeadersAndFooters.
What I'm doing is basically easy .... importing header and footer, reading the html response from a page that works with diffedent db data and create the final doc.
The import seems to work fine but I cannot replace the variable in the footer using the classic replaceVariableByText.
I've read on this forum that I cannot do this with newwordfrag.
I'll attach here my snippet.
Just to let you know, this script will work without the "variable replacement" part.
I hope someone will be so kind to help me.
Best regards,
Frank
<?php
//phpdocx lib
require_once ("../phpdocx/classes/CreateDocx.inc");
$docx = new CreateDocx();
//the docx file with $VARIABLE$ in the footer
$docx->importHeadersAndFooters('footerheader.docx');
$variables = array('VARIABLE' => 'example');
$docx->replaceVariableByText($variables);
ob_start();
include('print.php');
$page = ob_get_contents();
ob_end_clean();
$docx->embedHTML($page , array('downloadImages' => true ));
ob_end_clean();
$docx->createDocxAndDownload('upload/test');
?>