0
我必須從twif視圖生成PDF。 我正在嘗試使用http://www.michaelperrin.fr/2016/02/17/generating-pdf-files-with-symfony/PDF在Symfony 3中生成
但是,我有一個問題。
我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?
你檢查二進制路徑嗎?它和你的config.yml相同嗎? (也許它不是64位版本) –