PDF在Symfony 3中生成

时间:2016-07-10 15:47:40

标签: php symfony

我必须从twif视图生成PDF。 我正在尝试使用此http://www.michaelperrin.fr/2016/02/17/generating-pdf-files-with-symfony/

但是,我有一个问题。

我的config.yml

knp_snappy:
    pdf:
        enabled:    true
        binary:     %kernel.root_dir%/../vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64

我的控制器:

$html = $this->render('order/pdf.html.twig');
$filename = sprintf('test-%s.pdf', date('Y-m-d'));

$response = new Response();

$response->setContent($this->get('knp_snappy.pdf')->generateFromHtml($html, '/home/xxx/domains/xxx.hekko.pl/public_html/web/pdf/test.pdf'));
$response->setStatusCode(Response::HTTP_OK);
$response->headers->set('Content-Type', 'application/pdf');

我有错误

[2016-07-10 14:54:02] request.CRITICAL: Uncaught PHP Exception RuntimeException: "The exit status code '127' says something went wrong: stderr: "sh: wkhtmltopdf: command not found " stdout: "" command: wkhtmltopdf --lowquality '/tmp/knp_snappy5782456ab8c340.15653998.html' '/home/xxx/domains/xxx.hekko.pl/public_html/web/pdf/test.pdf'."

有什么问题?

我有共享主机,也许我必须有VPS?

1 个答案:

答案 0 :(得分:0)

是的,我认为Ugo是对的,我认为在Red Hat Enterprise Linux上安装时我看到了同样的信息。

使用uname -a检查您的体系结构并验证您是否拥有正确版本的" wkhtmltopdf"安装。