I am trying to replace a variable $PageNo$ in header of the templte .docx file. However it replace the whole header with the value of variable.
Below is the script I am using.
Could some body tell what's wrong with it?
<?php
require_once '../../../classes/CreateDocx.php';
$docx = new CreateDocxFromTemplate('example_addFootnote_2.docx');
// create the Word fragment that is going to replace the variable
$wf = new WordFragment($docx);
// insert all the content in the Word fragment we are going to use for replacement
$wf->addText("hello I replaced the variable.");
$docx->replaceVariableByWordFragment(array('PageNo' => $wf), array( 'target' => "header"));
$docx->createDocx('example_replaceVariableByWordFragment_1');
print "OK";
?>
Header in template .docx file
Hello I am default header. 2mdc.com with random image:
Page Number: $PageNo$