image is not shown in pdf with laravel-snappy

658 Views Asked by At

I use barryvdh/laravel-snappy to generate pdf. But when I add an img it does not show.

Here's my code:

<img src="{{ asset('xx.jpeg') }}" style="height: 50px; width:100px">

but the area of image is blank(gray rectangle)

enter image description here

if I use this:

<img src="xx.jpeg" style="height: 50px; width:100px">

got this error:

enter image description here

1

There are 1 best solutions below

0
Tiago Carvalho On

For me it worked like this

$pdf = SnappyPdf::setOptions([
        'encoding' => 'utf-8',
        'enable-local-file-access' => true
    ])->loadView('report', compact('data'));

And in a blade file

<img alt="" src="{{ public_path().'/images/img.png' }}" height="75px" width="270px"/>

I used these options for the image to load, I hope it helps