DomPDF: Image not readable or empty

user3562712 picture user3562712 · Aug 28, 2014 · Viewed 66.5k times · Source

For some reason, DomPDF won't render an image included in the html that is being parsed:

PDF Image missing

However, the image is rendered on the page when it is returned as html:

HTML Image exists

I've looked at these issues and have make sure that DOMPDF_ENABLE_REMOTE is set to true and verified file permissions:
dompdf image not real image not readable or empty
Image error in DOMPDF for ZF2

Are there any other things that I should be checking for?

Answer

David P. P. picture David P. P. · Dec 11, 2014

Following helped me like charm, at least localy, and even with

def("DOMPDF_ENABLE_REMOTE", false);

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

Thanks to this: lost in code