Forum


Replies: 2   Views: 3474
Images imported from html
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 eperfa  · 19-11-2012 - 19:45

Hello,

This is more like a reminder and not an issue, it'll hopefully save a few hours for people having problems similar to me.

If you'd like to embed HTML that has images in it into a DOCX as a template variable, there are a few things to remember (the last one was the really big gotcha for me):

[list][*] Downloading remote images did not always work for us, so we download all the images before creating the document
[*] The copy() PHP method can download images from remote URLs, but only if allow_fopen_wrappers is set to true. This is not the case on many shared hosting environments, so it is advised to use the cURL library instead
[*] Only absolute URLs can be used in the SRC tags, so if you have relative URLs (which is normally the case with online WYSIWYG editors like TinyMCE), you have to manipulate the path
[*] If you use replaceTemplateVariableByHTML, you have to use the 'file:///' prefix for your local SRCs, as something goes seriously wrong inside while parsing the DOM tree of your HTML - otherwise you'll end up with a document lacking the images[/list]

Happy coding!

Adam