I am using DOMPDF to generate pdf.
Here is my pdf.blade.php:
<img src="{{ public_path() . '/images/logo.png' }}" id="logo" />
<table class="order_confirmation">
<tbody>
<tr>
<th>Company name</th>
<td>Name</td>
</tr>
<tr>
<th>Email</th>
<td>[email protected]</td>
</tr>
</tbody>
</table>
Here is my controller method:
public function pdf() {
$data = array();
$pdf = PDF::loadView('pdf', $data);
return $pdf->stream();
}
Here is error:
ErrorException in class.pdf.php line 4036: imagepng(.png): failed to open stream: Permission denied
And a stacktrace:
in class.pdf.php line 4036 at HandleExceptions->handleError('2', 'imagepng(.png): failed to open stream: Permission denied', '/Applications/XAMPP/xamppfiles/htdocs/blablacompany/vendor/dompdf/dompdf/lib/class.pdf.php', '4036', array('file' => '/Applications/XAMPP/xamppfiles/htdocs/blablacompany/public/images/logo.png', 'x' => '34.015748031496', 'y' => '606.8742519685', 'w' => '334.5', 'h' => '201', 'byte' => '6', 'img' => 'Resource id #278', 'eight_bit' => false, 'wpx' => '446', 'hpx' => '268', 'tempfile_alpha' => '.png', 'tempfile_plain' => '.png', 'imgalpha' => resource, 'c' => '256', 'allocated_colors' => array('000' => '0', '9598261', '12756008', '9993266', '15848487', '7493443', '12690472', '16309032', '14269479', '5586004', '11637804', '16243240', '8809018', '2169210', '12624680', '15256615', '6638155', '2366072', '5454677', '10256177', '13151271'...
Could you please help me?
P.S.
- I have tried also url('/images/logo.png') instead of public_path() . '/images/logo.png'
- I have chmod 777 on storage, vendors and also on public/images, but still not working...
ErrorException in image_cache.cls.php line 105: file_put_contents(): Filename cannot be empty
UPDATE:
- if I set chmod 754 and
return view('pdf')
-> image is not shown (as well as on other pages which are using images/ - if I set chmod 754 and
$pdf = PDF::loadView('pdf', $data); return $pdf->stream();
-> PDF is generated but image is stroked square - but if I set chmod 755 and
return view('pdf')
-> images is shown, but.. - when I try
$pdf = PDF::loadView('pdf', $data); return $pdf->stream();
I receive an error message:
ErrorException in image_cache.cls.php line 105: file_put_contents(): Filename cannot be empty