使用knp snappy bundle生成pdf - symfony2 [英] Using knp snappy bundle to generate pdf - symfony2
问题描述
我是symfony2的新手,非常喜欢使用外部库。
我想使用我的第一个第三方套餐 KNP Snappy套餐。
我完全是在git链接中告诉的。
{
require:{
knplabs / knp-snappy-bundle:dev-master
}
}
$ b // app / AppKernel.php
public function registerBundles()
{
$ bundles = array(
// ...
new Knp\Bundle\SnappyBundle\KnpSnappyBundle(),
app / config / config.yml
knp_snappy:
PDF:
启用:true
二进制:/ usr / local / bin / wkhtmltopdf
选项:[]
图片:
启用: true
binary:/ usr / local / bin / wkhtmltoimage
选项:[]
<然后,我在 ACME welcome controller to test
$ this-> get('knp_snappy.pdf') - > generate('http ://www.google.fr','/Symfony/file.pdf');
它表示 退出状态码'1'
stdout:
命令:/ usr / local / bin / wkhtmltoimage --formatjpg http://www.google.fr/Symfony/file.pdf。
p>
$ this-> get('knp_snappy.pdf') - > generateFromHtml(
$ this-> renderView (
'AcmeDemoBundle:Welcome:index.html.twig'),
'/Symfony/file.pdf'
);
显示 退出状态码'1'错误:
stderr:系统找不到指定的路径
stdout:
command:/ usr / local / bin / wkhtmltopdf --lowqualityC: \Windows\TEMP\knp_snappy530da4525584b8.92211088.html/Symfony/file.pdf。
什么我丢了?我需要安装任何东西吗?请描述我如何运行它并生成一个合适的pdf?我搜索了,我猜我需要安装wkhtmltoimage等,但从哪里和如何?
几个月后,但这里是帮助我的。
我将wkthmltopdf文件夹的路径放在双引号内。
knp_snappy:
pdf:
binary:\C:/ Program Files(x86)/wkhtmltopdf/wkhtmltopdf.exe\
I'm new to symfony2 and very to use external libraries. I want to use the KNP Snappy Bundle, my first third party bundle.
I did exactly that is told in the git link.
{
"require": {
"knplabs/knp-snappy-bundle": "dev-master"
}
}
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
//...
new Knp\Bundle\SnappyBundle\KnpSnappyBundle(),
app/config/config.yml
knp_snappy:
pdf:
enabled: true
binary: /usr/local/bin/wkhtmltopdf
options: []
image:
enabled: true
binary: /usr/local/bin/wkhtmltoimage
options: []
Then I added following line in ACME welcome controller to test
$this->get('knp_snappy.pdf')->generate('http://www.google.fr', '/Symfony/file.pdf');
It says The exit status code '1' says something went wrong:
stderr: "The system cannot find the path specified.
"
stdout: ""
command: /usr/local/bin/wkhtmltoimage --format "jpg" "http://www.google.fr" "/Symfony/file.pdf".
I tried
$this->get('knp_snappy.pdf')->generateFromHtml(
$this->renderView(
'AcmeDemoBundle:Welcome:index.html.twig'),
'/Symfony/file.pdf'
);
It shows The exit status code '1' says something went wrong:
stderr: "The system cannot find the path specified.
"
stdout: ""
command: /usr/local/bin/wkhtmltopdf --lowquality "C:\Windows\TEMP\knp_snappy530da4525584b8.92211088.html" "/Symfony/file.pdf".
What I'm missing? Do I need to install anything ? Please describe how can I run it and generate a proper pdf????? I searched, I'm guessing I need to install wkhtmltoimage etc. But from where and how?
Few months later, but here is what helped me.
I put the path to wkthmltopdf folder in escaped double quotes.
knp_snappy:
pdf:
binary: "\"C:/Program Files (x86)/wkhtmltopdf/wkhtmltopdf.exe\""
这篇关于使用knp snappy bundle生成pdf - symfony2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!