Closed
Description
Here is my code in controller:
public function printmeAction()
{
$file = "twig-test.pdf";
$html = $this->renderView(
'AppBundle::printme.html.twig',
array(
'msg' => 'WOW! You Printed Me :D',
'body' => true,
)
);
return new Response(
$this->get('knp_snappy.pdf')->getOutputFromHtml($html),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="'.$file.'"',
)
);
}
I got this error when printme action is called:
The exit status code '134' says something went wrong:
stderr: "QXcbConnection: Could not connect to display
Aborted"
OS: Debian 8 (Jessie)
wkhtmltopdf version is 0.12.1
knplabs/knp-snappy": "~0.4.2"
knplabs/knp-snappy-bundle": "~1.3"
Activity
akovalyov commentedon Oct 7, 2015
Not Snappy related - wkhtmltopdf/wkhtmltopdf#2037
You should update wkhtmltopdf to latest, see https://github.com/KnpLabs/snappy/blob/master/doc/faq.md#q-it-says-wkhtmltopdf-cannot-connect-to-x-server-or-xvfb-run-error-xvfb-failed-to-start. I will update the readme and include this exception to FAQ as well.
ykh commentedon Oct 7, 2015
@akovalyov Yes, you right. I just download and install latest debian package and it works fine!
So tnx :)
bluemanos commentedon Dec 13, 2015
I'm getting the error for 0.12.2.4 wkhtmltopdf as well :/
Xubuntu 15.10 64bit
akovalyov commentedon Dec 14, 2015
@bluemanos
It is really bad that you receive this exception. However, it is not
wkhtmltopdf
package support, so I am pretty sure that we can't help you, because it is nothing related to snappy package. Moreover, you haven't commented out the way you have installedwkhtmltopdf
.Please, check out that you have installed
libx11-6
,libxext6
andlibxrender1
(and all other required by the package deps).And I encourage you to comment on the existing issue in
wkhtmltopdf/wkhtmltopdf
repo next time if it is not related to SnappyBundle. It will also help the maintainers of this piece of software and users of it.rsaylor73 commentedon Jun 16, 2016
I had the same issue with CentOS 6.8. There is a bug somewhere with wkhtmltopdf. I ended up downloaded an older version and it worked.
https://jaimegris.wordpress.com/2015/03/03/how-to-install-wkhtmltopdf-in-centos-6-5/
rubenvdlinde commentedon Oct 10, 2016
I stil get this error on on a ubuntu16 server, be it on symfony2 and php 6.2. The problem keeps showing up al the way to wkhtmltopdf 0.13 so it seems that the problem is here to stay. That does have something to do with the internal workings of QX3 v.s. QX5 (wkhtmltopdf switched to the later.
A clean solution is to use xvfb from kpnSnappy and ad a line in the Abstraggenerator::buildCommand that adds
xvfb-run --server-args="-screen 0, 1024x768x24"
to the comandlineAirmovz commentedon Feb 7, 2017
@rubenvdlinde How did you add
xvfb-run
onAbstractgenerator::buildCommand
? Wherein it is located atvendor
directory.ykh commentedon Feb 8, 2017
Try this (works for me):
http://download.gna.org/wkhtmltopdf/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
ghost commentedon May 2, 2017
Works great on our Ubuntu 16.04 servers. See work-around here:
wkhtmltopdf/wkhtmltopdf#2037 (comment)
See post from @masterkorp on that page (I do not take credit for this):
lyberteam commentedon Jul 14, 2017
For thous, who use Symfony (my version is 3.3.2) you can simply add this to config.yml file in the knp_snappy section: