Forum


Replies: 5   Views: 4136
Lib crashes when i try to replace a variable and a placeholder (both in header)
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.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by jdespatis  · 15-07-2014 - 10:32

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

Posted by admin  · 15-07-2014 - 15:16

Hello, We're checking the issue. Regards.

Posted by admin  · 15-07-2014 - 15:22

Deleted by admin · 15-07-2014 - 15:22

Posted by admin  · 16-07-2014 - 10:47

We 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 :-)

Posted by pestes  · 08-08-2014 - 19:50

It looks as though my company is encountering the same issue. Would it be possible to have the patch emailed to us as well?

Posted by admin  · 09-08-2014 - 09:30

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.