I'm encountering the strangest issue, and it only happens on Snappy.
I'm using an img tag to dispay an image in the PDF. I'm using the fully qualified path to specify the image location.
For example,
public_path() . '/image.jpg'
returns
/home/vagrant/Code/Project/public/image.jpg
which I then embed in the html
<img src="{{public_path() . '/image.jpg'}}" />
This exact code works fine with DOMPDF as well as PhantomMagick. Snappy won't display the image.
I'm developing on Homestead, using PHP 7.1.1.
I can't use DOMPDF because it's not compatible with 7.1, and I can't use PhantomMagick because it's not allowing me to change the font family of the text which is a requirement for me.
Snappy is my only hope, and this problem seems to be so simple. I really feel like I've tried everything.
Okay after countless hours wasted I finally figured out what was going on.
It turns out that wkhtmltopdf was rendering the PDF differently than phantomjs or whatever DOMPDF uses, and my imgs were out of view. The img tags were using relative positioning with percentage based max-heights and max-widths. Since I was using images as headers, they were probably being displayed outside of the view. I was able to return the images back into view by using absolute positioning.
<img style="position:absolute; top:0px; left:0px; width:90px; height:115px;" src="{{public_path() . '/image.jpg'}}" />
I'll continue to tinker to fit my needs, but I hope this saves someone hours of hair-pulling.
I have a similar problem. I have a img tag in my pfd.blade view. When i use PDF::LoadView the the pdf never show. When i remove the img tag everything is ok.
<img src="{{ asset("/images/".$employee->profile_picture) }}"
height="256px">
I found the solution:
<img src="{{ public_path("/images/".$employee->profile_picture) }}"
height="256px">
Everything is ok now.
Thank you very much @legreco. After 6 hours of trying to solve this... finally i got the solution.
Most helpful comment
I found the solution:
<img src="{{ public_path("/images/".$employee->profile_picture) }}" height="256px">Everything is ok now.