我米試圖實現KNP活潑的捆綁,以顯示一個HTML頁面,從我的控制器的PDF文件。 我堅持這個錯誤:Symfony的2 KnpSnappy捆綁錯誤
The exit status code '1' says something went wrong:
stderr: "Loading pages (1/6)
[> ] 0%
[======> ] 10%
[==========> ] 18%
Warning: Failed to load file:///slick/slick.css (ignore)
Warning: Failed to load file:///slick/slick-theme.css (ignore)
Warning: Failed to load file:///clovis-app/style.css (ignore)
Warning: Failed to load file:///clovis-app/estimate.css (ignore)
Warning: Failed to load file:///clovis-app/res/clovis.png (ignore)
Warning: Failed to load file:///js/collection.js (ignore)
Warning: Failed to load file:///clovis-app/script.js (ignore)
Warning: Failed to load file:///clovis-app/estimate.js (ignore)
[============================================================] 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 1 due to network error: ContentOperationNotPermittedError"
stdout: ""
command: "C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe" --lowquality "C:\Users\Razgort\AppData\Local\Temp\knp_snappy55ae6cc4ad0353.17775155.html" "C:\Users\Razgort\AppData\Local\Temp\knp_snappy55ae6cc4ad41d0.64896673.pdf".
這裏是我的配置文件:
knp_snappy:
pdf:
enabled: true
binary: "\"C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe\""
options: []
image:
enabled: true
binary: "\"C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltoimage.exe\""
options: []
,這裏是我如何渲染視圖:
$html = $this->renderView('CompanyBundle:Estimate:edit.html.twig', array(
'estimate' => $estimate,
'estimateForm' => $estimateForm->createView(),
'articleForm' => $articleForm->createView(),
'articleSelectForm' => $articleSelectForm->createView(),
'manpowerForm' => $manpowerForm->createView(),
'manpowerSelectForm' => $manpowerSelectForm->createView(),
'workSelectForm' => $workSelectForm->createView(),
'workForm' => $workForm->createView(),
'bundleForm' => $bundleForm->createView(),
'bundleSelectForm' => $bundleSelectForm->createView(),
));
return new Response(
$this->get('knp_snappy.pdf')->getOutputFromHtml($html),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="file.pdf"'
)
);
我EARD有問題在MAMP上,我使用wamp,沒有看到任何問題。 我會很感激一些這方面的幫助=)
編輯:
我修改了一些東西,以第一生成PDF。我做到了。但pdf只包含我的登錄頁面。然後我將訪問權限添加到我的會話中,並且工作正常。但是,當我試圖發送它作爲這樣的迴應:
$session = $this->get('session');
$session->save();
session_write_close();
$pageUrl = $this->generateUrl('estimate_preview', array('id' => $id), true);
return new Response(
$this->get('knp_snappy.pdf')->getOutput($pageUrl, array('cookie' => array($session->getName() => $session->getId()))),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="file.pdf"'
)
);
它似乎不工作或者...有人有一個想法,爲什麼?
THX的意見 – Razgort