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
Hello,
We're checking the issue.
Regards.
Deleted by admin ·
15-07-2014 - 15:22We already patched this bug that only showed up incertain versions of PHP.
The patched classes will be released with 4.1 but in the meantime we will send you the patch by email.
Thanks for pointing this issue to us :-)
It looks as though my company is encountering the same issue. Would it be possible to have the patch emailed to us as well?
Hello,
This bug is fixed in the current phpdocx 4.0.1 that was uploaded about week ago. You just need to download the new package on MYPHPDOCX page after login.
Regards.