Wkhtmltopdf not support using unpatched qt

Information about bug

Sales invoices not generated by pressing PDF button

Module

accounts, selling

Version

ERPNext: v14.2.0 (version-14)
Frappe Framework: v14.8.0 (version-14)
wkhtmltopdf 0.12.6

Installation method

manual install

Server Error
Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 69, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 45, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 83, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1598, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/utils/print_format.py", line 129, in download_pdf
    frappe.local.response.filecontent = get_pdf(html)
  File "apps/frappe/frappe/utils/pdf.py", line 38, in get_pdf
    filedata = pdfkit.from_string(html, options=options or {}, verbose=True)
  File "env/lib/python3.10/site-packages/pdfkit/api.py", line 75, in from_string
    return r.to_pdf(output_path)
  File "env/lib/python3.10/site-packages/pdfkit/pdfkit.py", line 201, in to_pdf
    self.handle_error(exit_code, stderr)
  File "env/lib/python3.10/site-packages/pdfkit/pdfkit.py", line 155, in handle_error
    raise IOError('wkhtmltopdf reported an error:\n' + stderr)
OSError: wkhtmltopdf reported an error:
The switch --print-media-type, 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 --disable-smart-shrinking, is not support using unpatched qt, and will be ignored.QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-erpnext'
Exit with code 1 due to network error: TimeoutError

Hi,

How was wkhtmltopdf installed? Is this post relevant?

https://discuss.frappe.io/t/pdf-generate-problem/83123/18

Version 14 does not use wkhtmltopdf for generating PDf docs. It is supposed to be using some other PDF support code.

I do not remember what they are using, but I remember being surprised by the announcement. There is a thread here on the forum about it somewhere.

BKM

I don’t think wkhtmltopdf is removed.

pdfkit python library is wrapper for wkhtmltopdf. It needs patched wkhtmltopdf to be installed.

Installing it from os official repo sources will not work as expected. Download from Releases · wkhtmltopdf/wkhtmltopdf · GitHub and install.

This message has a clue. We need to try patched qt

2 Likes

I shooted the following commands after uninstalling wkhtmltopdf

*** install wkhtmltopdf and its dependencies
$$ wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb
$$ sudo dpkg -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb
$$ sudo wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
$$ sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb

After running the above commands the server error stop and I got

504 Gateway Time-out
nginx

wkhtmltopdf 0.12.6 (with patched qt)

Try: bench restart

I too was having similar issues and discovered the “non patched qt” problem.

I followed the steps found in “Answer 2” of the link below. This fixed it for me.
https://www.anycodings.com/1questions/1162085/how-to-install-wkhtmltopdf-patched-qt-without-compiling