Open GanonthaBr opened 4 months ago
If you are using images from local drive, you need to tell DomPDF to allow that filepath.
ex: if your images are in your storage/app/compressed folder :
Pdf::SetOptions(['chroot' => [Storage::drive('public')->path('compressed')] ])->loadView(.....)
And in your view, you have to put the full file path again
<img src='{{ Storage::drive('public')->path('compressed/myImage1.jpg') }}' />
@ZARk-be hi, be carefull, setOptions
remove all the configs
better use setOption
or add bool $mergeWithDefaults
argument
// with setOption
Pdf::setOption('chroot', [Storage::drive('public')->path('compressed')])->loadView(.....)
// or setting bool $mergeWithDefaults arg on setOptions
Pdf::setOptions(['chroot' => [Storage::drive('public')->path('compressed')]], true)->loadView(.....)
https://github.com/barryvdh/laravel-dompdf/blob/d7ccbc3af7f52fec496bc4aebd099f917b1d2a57/src/PDF.php#L152-L156 https://github.com/barryvdh/laravel-dompdf/blob/d7ccbc3af7f52fec496bc4aebd099f917b1d2a57/src/PDF.php#L163-L171
Embedd images like this <img src="{{ public_path('resources/img/logo-big.jpg') }}" id="brand" alt="Logo" >
I am using Laravel 11. On my generated pdf, the image is not being loaded.