barryvdh / laravel-dompdf

A DOMPDF Wrapper for Laravel
MIT License
6.66k stars 967 forks source link

Call to a member function stream() on string #877

Closed mukesh17mj closed 2 years ago

mukesh17mj commented 2 years ago

Using the below code to generate PDF from HTML and storing it to AWS bucket. The pdf gets stored to bucket but give error. Getting error in stream function Call to a member function stream() on string Also used output function in place of stream function but same error for output as well. Call to a member function output() on string

$html = View::make('frontend.courses.certificate', [
    'course'     => $this->course,
    'user'       => $this->user,
    'overAll'    => $this->course->total_duration,
]);
$pdf = App::make('dompdf.wrapper');
$pdf->setPaper('a4', 'landscape')->loadHTML($html->render());
\Storage::disk('s3')->put($s3Path, $pdf->stream(), 'public');

What can be the issue ?

Tried multiple ways as mentioned below but not working.

$html = View::make('frontend.courses.certificate', [
    'course'     => $this->course,
    'user'       => $this->user,
    'overAll'    => $this->course->total_duration,
]);

$pdf = PDF::setPaper('a4', 'landscape')->loadHtml($html);
\Storage::disk('s3')->put($s3Path, $pdf->stream(), 'public');

Also

$html = View::make('frontend.courses.certificate', [
    'course'     => $this->course,
    'user'       => $this->user,
    'overAll'    => $this->course->total_duration,
]);
$pdf = PDF::setPaper('a4', 'landscape')->loadHtml($html);
\Storage::disk('s3')->put($s3Path, file_get_contents($pdf), 'public');

This does not give any error but not able to open the pdf generated. Gives failed to load PDF Document.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any issues with PDF rendering itself that are not directly related to this package, should be reported on https://github.com/dompdf/dompdf instead. When having doubts, please try to reproduce the issue with just dompdf. If you believe this is an actual issue with the latest version of laravel-dompdf, please reply to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.