If you are using DOMPDF on a server environment that has a self-signed security certificate, or perhaps the certificate name doesn’t match what it should, DOMPDF will not load images or other assets without specifically creating a stream context that allows it to do so.
// DOMPDF version 0.7.0 use Dompdf\Dompdf; use Dompdf\Options; require_once 'dompdf/autoload.inc.php'; $options = new Options(); $options->set('isRemoteEnabled', TRUE); $dompdf = new Dompdf($options); $contxt = stream_context_create([ 'ssl' => [ 'verify_peer' => FALSE, 'verify_peer_name' => FALSE, 'allow_self_signed'=> TRUE ] ]); $dompdf->setHttpContext($contxt); // ...
For me this problem happened on the development environment (Ubuntu 16.04). I didn’t try it on the production environment, but it would have been fine there, because it has a valid security certificate.
Mailson says:
Thanks, you saved me!
Lucas says:
Thank you so much !!!
Sergio says:
Thank you. I’m from Brazil and your solution saved me. Thanks anyway!
Michael says:
Thanks dude
Alberto says:
Thank you, but where should we write that code?
Rodrigo Sandoval says:
Hey! Thanks!
Hendro PS says:
Thanks dude, you save my day !
claudio says:
Does not work for me 🙁
bichitra says:
showing undefined methods