html2pdf icon indicating copy to clipboard operation
html2pdf copied to clipboard

Insert image from a data URI

Open chrispytoes opened this issue 5 years ago • 1 comments

I am trying to use a data URI to display an image but it's throwing an exception that has no error message. I need to put images into my PDF that are inside a private directory without needing to expose them.

$mime_type = mime_content_type($file_path);
$image_data = base64_encode(file_get_contents($file_path));
$data_uri = "data: $mime_type;base64,$image_data";

When I try using $data_uri as an img src, it throws a blank error with no message.

chrispytoes avatar Nov 06 '20 04:11 chrispytoes

wait, what ??? but why you just do not put the $file_path into the src of the image tag ? look at examples, i never put url in the src of the images, i put path... using the "data:" is totally useless

spipu avatar Nov 06 '20 07:11 spipu