PDF converting error [Please assist]

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 60, in application
    response = frappe.api.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 49, in handle
    return 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 879, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/print_format.py", line 50, in download_pdf
    frappe.local.response.filecontent = 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 --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.No protocol specified
QXcbConnection: Could not connect to display :1

Remove wkhtmltopdf installed using apt-get previously (if previously installed).

sudo apt-get remove --purge wkhtmltopdf

Install dependencies.

sudo apt-get install openssl build-essential xorg libssl-dev

Download the static binary as per the architecture (i386/amd64). Extract it, change the file owner to match it with ERPNext OS user (Ex. frappe) and then copy it to /usr/local/bin.

wget http://download.gna.org/wkhtmltopdf/obsolete/linux/wkhtmltopdf-0.9.9-static-i386.tar.bz2
tar xvjf wkhtmltopdf-0.9.9-static-i386.tar.bz2
sudo chown root:root wkhtmltopdf-i386
sudo cp wkhtmltopdf-i386 /usr/local/bin/wkhtmltopdf

Hope this helps to correct your problem.

2 Likes

The object cannot be found. HTTP request 404 error

@WilbrodDreamChaser It’s always good habit to do little bit of searching on google with reference to what you have been provided.

wget http://download.gna.org/wkhtmltopdf/obsolete/linux/wkhtmltopdf-0.9.9-static-i386.tar.bz2

If wget causes 404 error, find version 0.9.9 (Even if listed under outdated on wkhtmltopdf.org, needed by Frappe/ERPNext to generate PDF files of various documents) version downloadable link from http://wkhtmltopdf.org/obsolete-downloads.html or http://wkhtmltopdf.org downloads page.

2 Likes

FYI … working with 0.11.0-rc1-static as well. Would be nice to include in install script if not already there.