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.
I have a template with an image placeholder in the header ($HEADERIMG$), and a variable in the header ($FOO$)
(screenshot of this template: http://screencast.com/t/Ruf9EGNb)
Then if I want to replace FOO and then HEADERIMG, with following code:
$docx = new \CreateDocxFromTemplate("replacePlaceholderImages2.docx");
$docx->replaceVariableByText(array("FOO" => 4), array("target" => "header"));
$docx->replacePlaceholderImage('HEADERIMG', 'images/user.png', array("target" => "header"));
$docx->createDocx('/tmp/example_replacePlaceholderImages_2');
=> I get an exception: ContextErrorException: Warning: DOMDocument::loadXML(): Empty string supplied as input in [...]/phpdocx/classes/CreateDocxFromTemplate.inc line 1096
As a second try, if I want to replace the placeholder HEADERIMG and then the variable FOO, with following code:
$docx = new \CreateDocxFromTemplate("replacePlaceholderImages2.docx");
$docx->replacePlaceholderImage('HEADERIMG', 'images/user.png', array("target" => "header"));
$docx->replaceVariableByText(array("FOO" => 4), array("target" => "header"));
$docx->createDocx('/tmp/example_replacePlaceholderImages_2');
=> I get an exception: FatalErrorException: Error: Call to a member function registerXPathNamespace() on a non-object in [...]/phpdocx/classes/CreateDocxFromTemplate.inc line 1271
Am I using the lib in a bad manner ?
Thanks for your feedback