Search code examples
phpimagepdfhttpsdompdf

Images are not displayed with DOMPDF with HTTPS


I'm creating a pdf with DOMPDF and it's working fine on local and in a server with HTTP but when the source is in a server with HTTPS the images are not displayed.

$options->set('isRemoteEnabled', TRUE);
$dompdf = new Dompdf($options);

$context = stream_context_create([ 
    'ssl' => [ 
        'verify_peer' => FALSE, 
        'verify_peer_name' => FALSE,
        'allow_self_signed'=> TRUE 
    ] 
]);
$dompdf->setHttpContext($context);

Solution

  • To fix this I've used the path "var/www/mysite/public/images/image.jpg". I couldn't fix the problem with a background image, so I use the image with position absolute instead of background image with css.