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>test@email.com</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?
PS
ErrorException in image_cache.cls.php line 105: file_put_contents(): Filename cannot be empty
UPDATE:
return view('pdf')
-> image is not shown (as well as on other pages which are using images/ $pdf = PDF::loadView('pdf', $data); return $pdf->stream();
$pdf = PDF::loadView('pdf', $data); return $pdf->stream();
-> PDF is generated but image is stroked square return view('pdf')
-> images is shown, but.. $pdf = PDF::loadView('pdf', $data); return $pdf->stream();
$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
I figured out how to deal with it:
<img src="{{ public_path() . '/images/somepicture.jpg' }}" id="logo" />
), public_path()
won't work if want to load view return view('yourview');
Use only .jpg , .png won't work
chmod 755 your image folder
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.