Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I got this error: "QXcbConnection: Could not connect to display Aborted" #116

Closed
ykh opened this issue Oct 7, 2015 · 10 comments
Closed

Comments

@ykh
Copy link

ykh commented Oct 7, 2015

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"

@akovalyov
Copy link
Contributor

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
Copy link
Author

ykh commented Oct 7, 2015

@akovalyov Yes, you right. I just download and install latest debian package and it works fine!
So tnx :)

@ykh ykh closed this as completed Oct 7, 2015
@bluemanos
Copy link

I'm getting the error for 0.12.2.4 wkhtmltopdf as well :/

root@mia:/tmp# wkhtmltopdf -V
wkhtmltopdf 0.12.2.4

Xubuntu 15.10 64bit

@akovalyov
Copy link
Contributor

@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 installed wkhtmltopdf.
Please, check out that you have installed libx11-6, libxext6 and libxrender1 (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
Copy link

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
Copy link

rubenvdlinde commented 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 comandline

@Airmovz
Copy link

Airmovz commented Feb 7, 2017

@rubenvdlinde How did you add xvfb-run on Abstractgenerator::buildCommand? Wherein it is located at vendor directory.

@ykh
Copy link
Author

ykh commented Feb 8, 2017

@ghost
Copy link

ghost commented 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):

$ /usr/bin/xvfb-run /usr/bin/wkhtmltopdf

@lyberteam
Copy link

lyberteam commented 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:

   knp_snappy:
       pdf:
           enabled:    true
           binary:     /usr/bin/xvfb-run /usr/bin/wkhtmltopdf
           options:    []

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants