laravel-dompdf: Images not shown in PDF
I’m not sure why but when I add in images, the pdf doesn’t display it. However, when I see the html on the page, it shows up normally.
This is the error that displays on the pdf
Image not readable or empty
/images/logo.png
Not sure what it is, but I can see the images in the HTML that is used to generate the PDF.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 32 (1 by maintainers)
This trick works for me! 😃
Convert your Image file to Base64 format with these lines of code, and then include the
$imageData
intosrc
attribute of<img>
tag instead of an image URL.This might help someone
This should do the trick.
Can you use the full path? Like http://mydomain.com/images/logo.png? Use
asset('images/logo.png')
for example.src=“http://www.example.com/assets/images/image.png”
You just need to change it to,
src=“assets/images/image.png”
HI Guys, I am still having this problem. My setup is as follows. And I am using
Laravel 5.4.36
The Image is not Showing up on the PDF. I tried using @hzung example but a bit simpler.OS
PHP Version
Composer File
Controller
HTML :: customer/carFact.blade.php
The Image is not Showing up on the PDF.
Can’t get it to work on localhost:8000 with
php artisan serve
Hi, I currently have a problem. Images was showing for 3 or 4 generated pdf but now no images are shown.
I am using the @AMABK code:
It was working as I said for 3 or 4 generated files but now the image is not showed. I save each html on a file and such files the image is showed. Now I am trying with decoded image but is unsuccessful.
I am using the version 0.4 for laravel 4.2
For png files I simply do:
for SVG files in this case this is an background image
/etc/hosts file
I actually didn’t expect this to work, but it does! How’s this different from
public_path($image_path)
? 😕Edit: Never mind. It seems that you need to specify your local path e.g.
/var/www/path/to/file
instead ofhttp://app.local/path/to-file
. Makes sense.What do you mean with “hosts” file?
On Fri, Jul 31, 2015 at 2:30 PM, Dmitriy Galievskiy < notifications@github.com> wrote:
Found where is a problem! Just add the site to the hosts file, and all will works!