Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lilo's avatar
Level 2

Image not found or type unknown

Hi,

I convert my blade to pdf using dompdf but on the image field, this is written: Image not found or type unknown

How can I display my image on pdf?

0 likes
1 reply
automica's avatar

@lilo if you want to embed images in domPDF you need to base64 encode it and embed rather than load it like you would do it it was html.

// A few settings
$image = 'cricci.jpg';

// Read image path, convert to base64 encoding
$imageData = base64_encode(file_get_contents($image));

// Format the image SRC:  data:{mime};base64,{data};
$src = 'data:'.mime_content_type($image).';base64,'.$imageData;

// Echo out a sample image
echo '<img src="'.$src.'">';

see https://davidwalsh.name/data-uri-php

Please or to participate in this conversation.