Skip to content

Images not rendering in PDF #785

Answered by hyphen81
hyphen81 asked this question in Q&A
Discussion options

You must be logged in to vote

in case anyone else runs into this, the answer was to base64 encode the image:

            $imagePath = public_path('images/my-image.png');
            $imageType = pathinfo($imagePath, PATHINFO_EXTENSION);
            $imageData = file_get_contents($imagePath);
            $data['base64'] = 'data:image/' . $imageType . ';base64,' . base64_encode($imageData);

and then in my blade file:

			<img src="{{ $data['base64'] }}" alt="" style="max-height:3rem;">

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@plweil
Comment options

Answer selected by hyphen81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants