I am using DomPDF for creating PDF from HTML.
it is working but image not showing there. in pdf, Images replace by cross Icon.
How can I resolve it?
- 3 years ago
How are you loading your HTML document into dompdf?
$dompdf->load_html_file()? To access a PHP-generated image you should be using the latter. Additionally, unless you are loading the document through a web server dompdf will grab the file itself, not the rendered file. Since image.php is not a valid image type dompdf will fail to load it.
There are two solutions:
- Load your document through your web server, e.g.
$dompdf->load_html_file('http://example.com/mydoc.html');. When you do this the image reference will be interpreted as
- Reference your image using a full URL (including domain) so that your server processes it before sending it back to dompdf, e.g.
<img src="http://example.com/image.php" />.
- 3 years ago
Following helped me like charm, at least localy, and even with
The solution is to change the image SRC to the absolute path on the server, like this:
<img src="/var/www/domain/images/myimage.jpg" />
All of the following worked for me:
<img src="<?php echo $_SERVER["DOCUMENT_ROOT"].'/placeholder.jpg';?>"/> <img src="<?php echo $_SERVER["DOCUMENT_ROOT"].'\placeholder.jpg';?>"/> <img src="<?php echo $_SERVER["DOCUMENT_ROOT"].'./placeholder.jpg';?>"/>
$_SERVER["DOCUMENT_ROOT"] is C:/wamp/www/ZendSkeletonApplication/public