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 2 placeholders in the header ($HEADERIMG$ and $LOGO$) and I use the following test code:
$docx = new \CreateDocxFromTemplate("replacePlaceholderImages.docx");
$docx->replacePlaceholderImage('HEADERIMG', 'images/user.png', array("target" => "header"));
$docx->replacePlaceholderImage('LOGO', 'images/qrcode.png', array("target" => "header"));
$docx->createDocx('/tmp/example_replacePlaceholderImages_1');
And i get the PHP error:
ContextErrorException: Warning: DOMDocument::loadXML(): Empty string supplied as input in [...]/phpdocx/classes/CreateDocxFromTemplate.inc line 1096
(indeed, after first replacing HEADERIMG placeholder, the lib seems to clean the LOGO placeholder in the same time, from pov)
=> bug in library or I'm badly using the lib ?
Thanks for your feedback
Here is a screenshot of the template used:
http://screencast.com/t/mBbQNqRSuY
It's in fact the template tuned a little from: http://www.phpdocx.com/api-documentation/templates/replace-placeholder-image-Word-document
Hello,
You can't duplicate the same image, because Word doesn't add two images but only one.
You need to use two different files or use the method replaceVariableByWordFragment with text placeholders.
Regards.
Ok, so I've done a new try:
I've created a new template from scratch, with 2 different images as placeholders ($logo$ and $qrcode$) in the header
(here is my template rendered: http://screencast.com/t/gyZgkIEHY2y, I can send it to you, no problem)
And then I replace those 2 placeholders with 2 different images (indeed, all those 4 images are all different), thanks to the code:
$docx = new \CreateDocxFromTemplate("TestTemplate2.docx");
$docx->replacePlaceholderImage('logo', 'images/user.png', array("target" => "header"));
$docx->replacePlaceholderImage('qrcode', 'images/event.jpg', array("target" => "header"));
$docx->createDocx('/tmp/example_replacePlaceholderImages_1');
But I get the same exception (and the resulting docx is not generated):
ContextErrorException: Warning: DOMDocument::loadXML(): Empty string supplied as input in [...]/phpdocx/classes/CreateDocxFromTemplate.inc line 1096
Any idea ?
Hello,
Please send the questions to contact@phpdocx.com to get the support.
Regards.