使用 DomPdf 从 html 创建 PDF。
$html = '<html><head><body>Test</body></head></html>
$pdf = \App::make('dompdf.wrapper');
$pdf->loadHTML($html);
$pdf->render();
return $pdf->stream();
获取错误:
Call to protected method Barryvdh\DomPDF\PDF::render() from context 'App\Http\Controllers\TestController'
当删除“
$pdf->render();
创建 PDF 文件,但 html 代码困惑...
Tnx,P
最佳答案
我猜你正在使用 https://github.com/barryvdh/laravel-dompdf ?
您收到错误是因为您尝试从 Controller 调用 protected 方法。
文档说您可以执行以下操作:
You can save it to a file, or stream (show in browser) or download.
$pdf->save('myfile.pdf')
$pdf->stream();
$pdf->download('invoice.pdf');
关于html - Laravel 5 DomPdf 渲染错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32394880/