wertyu
wertyu

Reputation: 121

image is not shown in pdf with laravel-snappy

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

Upvotes: 0

Views: 1006

Answers (1)

Tiago Carvalho
Tiago Carvalho

Reputation: 1

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

Upvotes: 0

Related Questions