【发布时间】:2014-03-19 19:33:50
【问题描述】:
这可能是一个非常简单的,但我无法让它工作......
我想从 Blade View 生成 PDF。
为了做到这一点,我通过 composer 安装了:
"ignited/laravel-pdf": "1.*",
"h4cc/wkhtmltopdf-i386": "*",
"h4cc/wkhtmltopdf-amd64": "*"
我的服务提供者和门面设置如下:
'Ignited\Pdf\PdfServiceProvider',
'PDF' => 'Ignited\Pdf\Facades\Pdf'
我已经发布了配置设置并尝试了两种配置。
return array(
# Uncomment for 32-bit systems
'bin' => base_path() . '/vendor/h4cc/wkhtmltopdf-i386/bin/wkhtmltopdf-i386'
# Uncomment for 64-bit systems
#'bin' => base_path() . '/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'
# Add any global Wkhtmltopdf options here
#'no-outline',
#'margin-top' => 0,
#'margin-right' => 0,
#'margin-bottom' => 0,
#'margin-left' => 0,
);
我的控制器如下:
public function getPDF($id)
{
$pdf = PDF::make();
$pdf->addPage('<html><head></head><body><b>Hello World</b></body></html>');
$pdf->send();
}
但是当我访问该页面时,我只是得到一个白屏。
一旦我最终显示 Hello World,我希望能够将视图传递给它以呈现为 PDF。
我的想法是,laravel-pdf 根本没有做任何事情,就像我在 $pdf->send() 之后 dd('helloooo') 一样,当我在浏览器中访问该页面时,我只是得到 string(8) "helloooo"。
有什么想法还是我太笨了?
【问题讨论】:
-
您是否运行过 composer install 和 composer dump-autoload? WSOD 也通常是因为文件系统写入权限问题
标签: php pdf laravel wkhtmltopdf