0

Hello I am developing an web with python Flask in a linux server, in doing so I am trying to use pdfkit and wkhtmltopdf.

I am using a linux server(ubuntu).

In Putty, after logging into my server, at root@myname:~# I downloaded pdfkit using apt-get, and downloaded wkhtmltopdf. And I go to python by typing python on the command. And I am trying to convert a url into a pdf file by typing in python;

import pdfkit

pdfkit.from_url('sample url','output.pdf') 

here I got an error saying:

IOError: wkhtmltopdf exited with non-zero code -6. error:
QXcbConnection: Could not connect to display.

What went wrong? installing was a problem? or which part?

And also, if it works correctly, where can I find the output file? which directory? I am using WinSCP to manage files.

  • as stated in the above error, you have no display (graphically speaking). I assume that you're using the command-line only Ubuntu server distro? – Joe May 6 '16 at 8:36
0

I faced the same issue with similar use, it means that you don't have any graphic screen available on your machine.

To solve this try to install xvfb and use the package wkhtmltopdf on which pdfkit is written.

In wkhtmltopdf we can select auto selecting available screen by -a switch, so that kind of solves problem for me. And you can call wkhtmltopdf from subprocess, so that kind of works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.