PDF generate problem

File “/home/ecom/frappe-bench/env/lib/python3.6/site-packages/pdfkit/pdfkit.py”, line 159, in to_pdf
raise IOError(“wkhtmltopdf exited with non-zero code {0}. error:\n{1}”.format(exit_code, stderr))
OSError: wkhtmltopdf exited with non-zero code 1.

error:
The switch --print-media-type, is not support using unpatched qt, and will be ignored.The switch --footer-html, is not support using unpatched qt, and will be ignored.The switch --disable-smart-shrinking, is not support using unpatched qt, and will be ignored.QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to ‘/tmp/runtime-ecom’
qt.qpa.screen: QXcbConnection: Could not connect to display
Could not connect to any X display.

Thank You.

Facing the same situation … did you reach anything?

what is your wkhtmltopdf s version ? do you have images in your print format ?

wkhtmltopdf 0.12.5 (with patched qt)

yes, there is QR and image

does it work with a blank page ? or just text ?

@bahaou much appreciate you assistant.
I have upgraded to 12.6 now , some invoice templates are getting generated now but some aren’t (eg KSA VAT template that include QR)

does your application run on a server ?

Ubuntu 20

is it online ? or locally hosted ?

hosted on GCP

got to site -> site name , and edit the site config.json file . add the following line :
“host_name”:your server url or ip address",
and run a bench migrate

tried >> bench migrate
got error >> Site site1.local does not exist!

omg, what happened ?

don’t worry , im not using it .
I might have deleted it earlier.

I noticed that the QR is not shown on the invoice, that means file is not found correct?

just try to create a new site or recreate the old one . anyways the image problem in pdf is the host name in site_config , I am sure.

1 Like

my issue is solved finally I upgrade the latest version of wkhtmltopdf.

1 Like

:+1: Solved
As u stated, by wkhtmltopdf upgrade .
Thank you for sharing

Can anyone shed some light on exactly how they upgraded to the latest version of wkhtmltopdf ??

I thought the version in use had special changes specific to frappe framework.

I would like to upgrade my version as well but I am unsure exactly how. I have read so many horror stories about trying to do it from the repo that you end up with versions missing qr patches or missing frappe patches.

Any help or pointers to a success story would be greatly appreciated.

BKM :nerd_face:

Frappe/ERPNext is just using the ordinary wkhtmltopdf found here:
https://wkhtmltopdf.org/downloads.html

It’s a binary executable (written in C++). So you can just delete your current one, and install the latest (0.12.6 at the time of this post). Save it somewhere on your PATH, and you’re good to go.