我正在使用KNP Snappy和Symfony2。當我使用從控制器我得到以下響應的響應:控制器的Symfony2 - 使用KNP生成PDF從控制器中快速生成404
The exit status code '2' says something went wrong:
stderr: "Loading pages (1/6)
[> ] 0%
[======> ] 10%
[============================> ] 48%
[============================================================] 100%
Counting pages (2/6)
[============================================================] Object 1 of 1
Resolving links (4/6)
[============================================================] Object 1 of 1
Loading headers and footers (5/6)
Printing pages (6/6)
[> ] Preparing
[===================> ] Page 1 of 3
[=======================================> ] Page 2 of 3
[============================================================] Page 3 of 3
Done
Exit with code 2 due to http error: 404 Page not found
"
stdout: ""
command: /usr/bin/wkhtmltopdf --lowquality --no-outline '/tmp/knp_snappy527f3354ad21d2.78976975.html' '/tmp/knp_snappy527f3354ad6e37.45993260.pdf'.
部分看起來是這樣的:產生
$html = $this->renderView('MyBundle:Visit:print.html.twig', array(
'visit' => $visit,
'themes' => $themes
));
return new Response(
$this->get('knp_snappy.pdf')->getOutputFromHtml($html),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="file.pdf"'
)
);
的文件,它看起來很好。但是,迴應是錯誤的。
有誰知道問題可能是什麼?
嘗試,而無需創建PDF,如果你得到任何錯誤檢查返回渲染的模板 - 缺少變量,語法錯誤,... – nifr