Skip to content

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

Closed
@ykh

Description

@ykh

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

akovalyov commented on Oct 7, 2015

@akovalyov
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

ykh commented on Oct 7, 2015

@ykh
Author

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

bluemanos

bluemanos commented on Dec 13, 2015

@bluemanos

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

akovalyov commented on Dec 14, 2015

@akovalyov
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

rsaylor73 commented on Jun 16, 2016

@rsaylor73

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

rubenvdlinde commented on Oct 10, 2016

@rubenvdlinde

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

Airmovz commented on Feb 7, 2017

@Airmovz

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

ghost

ghost commented on May 2, 2017

@ghost

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

lyberteam commented on Jul 14, 2017

@lyberteam

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ykh@akovalyov@rubenvdlinde@bluemanos@Airmovz

        Issue actions

          I got this error: "QXcbConnection: Could not connect to display Aborted" · Issue #116 · KnpLabs/KnpSnappyBundle