2

using DomPdf to create PDF from html.

$html = '<html><head><body>Test</body></head></html>
$pdf = \App::make('dompdf.wrapper');
$pdf->loadHTML($html);
$pdf->render();
return $pdf->stream(); 

Get error:

Call to protected method Barryvdh\DomPDF\PDF::render() from context 'App\Http\Controllers\TestController'

When remove "

$pdf->render();

Create PDF file,but mess html code...

Tnx, P

1 Answer 1

3

I'm guessing you're using https://github.com/barryvdh/laravel-dompdf?

You're receiving the error because you're trying to call a protected method from your controller.

The docs say you can do the following:

You can save it to a file, or stream (show in browser) or download.

$pdf->save('myfile.pdf')
$pdf->stream();
$pdf->download('invoice.pdf');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.