hellaminx hellaminx - 2 years ago 563
PHP Question

DomPDF: Image not readable or empty

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 Source

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

Thanks to this: lost in code

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download