Open matiassemelman opened 4 months ago
I am facing the same issue but with Laravel 11.x.x
did you try with asset()
?
Also https://github.com/barryvdh/laravel-dompdf/issues/1059#issuecomment-2218671789
I'm facing the same issue in Laravel 11.x :-(
Can confirm.
Tried it with helper methods like asset
, tried absolute and relative paths, also tried SetOptions
(Which, even if it would be expected behaviour, would be weird)
I just get this screen.
What actually works and it's a workaround for me: Just encode your file in base64 ;)
'logo' => 'data:image/png;base64,' . base64_encode(file_get_contents(public_path('images/logo.png'))),
Hm actually, got to apologize: Made it work with public_path
.
@matiassemelman did you try it without the leading ./
in your scenario?
In my example:
src="{{ public_path('/images/logo.png') }}"
it does work
but in your scenario the output would be something like: "/application/public/./images/logo.png"
the dot actually ruins the path
Laravel 11.x
I was able to fix the problem with:
$imagePath = public_path('images/logo.png');
$image = "data:image/png;base64," . base64_encode(file_get_contents($imagePath));
inside my controller and passed the $image vairiable down to the view which allowed me to used it inside my <img>
tag easily like this: <img src="{{$image}}"/>
Check my Controller here: https://github.com/GANONTHA/Belle-House-Automated-Invoice/blob/master/app/Http/Controllers/PDFExportController.php
Laravel 11.x
I was able to fix the problem with:
$imagePath = public_path('images/logo.png');
$image = "data:image/png;base64," . base64_encode(file_get_contents($imagePath));
inside my controller and passed the $image vairiable down to the view which allowed me to used it inside my
<img>
tag easily like this:<img src="{{$image}}"/>
Check my Controller here: https://github.com/GANONTHA/Belle-House-Automated-Invoice/blob/master/app/Http/Controllers/PDFExportController.php
bro, you saved my live, i was figuring this problem for days
Hello there, I'm using Laravel 10.10, and package 2.1.
I have my logo on public/ folder, just there. This is my function: private function generateLogo() { return "<img src='{{public_path('./pathful-logo') }}' alt='pathful-logo' class='logo' />"; }
I used public_path(), base_path(), with and without {{ }}.