html - Laravel 5 DomPdf 渲染错误

标签 html laravel-5 dompdf

使用 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/

相关文章:

css - 如何计算移动设备的宽度和高度

html - 用于访问和检索信息的 Perl 或 MySQL

php - Laravel 在增加字段时禁用自动 "updated_at"

Laravel 集合对集合中的多列求和

php - 如何为 DOMPDF 中的特定 HTML 元素设置全宽

html - 在保持对齐的同时减小文本宽度

html - 从父表内的表中的最后一个单元格中删除 border-left

php - laravel/php - 按 id 分组但仍然获取每一行数据

带附件的 Laravel 邮件给出 fopen() : null bytes error

php - Laravel:尝试获取 PDF 时出现 DOMPDF 错误