DOMPDF: Image not found or type unknown

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/';
$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 
// ...

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.

Posted in PHP

9 thoughts on “DOMPDF: Image not found or type unknown”

Comments are closed.