Forum


Replies: 4   Views: 4162
"replacetemplatevariablebyhtml" and "downloadimages"
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 HalloWelt  · 22-03-2013 - 09:29

Hi,
I've got a little issue with the "replaceTemplateVariableByHTML" method. When I try to embed images using the "downloadImages" option Word reports "unreadable content" and that the file is corrupted. Word _can_ actually open the files and the content is alright, but the error message makes the user feel uncomfortable.
First I tried the example "examples/intermediate/HTML.php" which uses 'addHTML' method and works fine but does not embed (download) the images.
After that I tried the following code:[code]
$oPHPDocX = new CreateDocx();
$oPHPDocX->addTemplate( $sUploadPath.'/template/Template.docx' );
$oPHPDocX->replaceTemplateVariableByHTML(
'CONTENT',
'block',
'<p>Some Text</p>
<img src="file:///development/PHPDOCX/res/city.jpg" />
<p>Some Text</p>',
array(
'isFile' => false,
'parseDivsAsPs' => true,
'downloadImages' => true,
'wordStyles' =>array(
'<p>' => 'Standard'
)
)
);
[/code]
This code causes the error described above. If I remove the "'downloadImages' => true," line the error disappears. But that's not what I need. I have to include the images in the DOCX file.

I'd be very grateful for some hints. Btw.: I'm using PHPDOCX v3.2.

best regards,
Robert Vogel

[edit]: I've already tried the tipps from this post: [url]http://www.phpdocx.com/help/forum?vasthtmlaction=viewtopic&t=2820.0[/url]