[V7] Wkhtmltopdf error

I ran into an error when I tried to email a PDF on my new install of V7. The error was that wkhtmltopdf was not installed. I then logged in to my console and ran as a test:

wkhtmltopdf http://erpnext.com erpnext.pdf

It confirmed that it wasn’t installed and provided the command to do the install which I ran from root. I then ran

bench update

Now I’m getting this error message in ERPnext when I try to send an RFQ in an email:

Traceback (most recent call last):
File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 55, in application
response = frappe.handler.handle()
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 19, in handle
execute_cmd(cmd)
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 36, in execute_cmd
ret = frappe.call(method, *frappe.form_dict)
File "/home/frappe/frappe-bench/apps/frappe/frappe/init.py", line 876, in call
return fn(args, **newargs)
File 
"/home/frappe/frappe-bench/apps/erpnext/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py",
 line 148, in send_supplier_emails
rfq.send_to_supplier()
File 
"/home/frappe/frappe-bench/apps/erpnext/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py",
 line 59, in send_to_supplier
self.supplier_rfq_mail(rfq_supplier, update_password_link, self.get_link())
File 
"/home/frappe/frappe-bench/apps/erpnext/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py",
 line 128, in supplier_rfq_mail
attachments = self.get_attachments()
File 
"/home/frappe/frappe-bench/apps/erpnext/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py",
 line 140, in get_attachments
attachments.append(frappe.attach_print(self.doctype, self.name, doc=self))
File "/home/frappe/frappe-bench/apps/frappe/frappe/init.py", line 1171, in attach_print
"fcontent": get_print(doctype, name, print_format=print_format, style=style, html=html, as_pdf=True, doc=doc)
File "/home/frappe/frappe-bench/apps/frappe/frappe/init.py", line 1154, in get_print
return get_pdf(html)
File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/pdf.py", line 16, in get_pdf
pdfkit.from_string(html, fname, options=options or {})
File "/home/frappe/frappe-bench/env/src/pdfkit/pdfkit/api.py", line 68, in from_string
return r.to_pdf(output_path)
File "/home/frappe/frappe-bench/env/src/pdfkit/pdfkit/pdfkit.py", line 143, in to_pdf
raise IOError("wkhtmltopdf exited with non-zero code {0}. error:\n{1}".format(exit_code, stderr.decode("utf-8")))
IOError: wkhtmltopdf exited with non-zero code -6. error:
The switch --no-outline, is not support using unpatched qt, and will be 
ignored.The switch --header-html, 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 --print-media-type, is not 
support using unpatched qt, and will be ignored.QXcbConnection: Could 
not connect to display

I’m not sure where to go from here.

In case your ERPNext runs on Debian, then workaround for this issue is to call wkhtmltopdf inside xvfb.

xvfb-run -- /usr/bin/wkhtmltopdf
1 Like