WKHTMLTOPDF error

Hi,

iwonder how to fix this :
Traceback (innermost last):
File “/home/myme/frappe-bench/apps/frappe/frappe/app.py”, line 54, in application
response = frappe.api.handle()
File “/home/myme/frappe-bench/apps/frappe/frappe/api.py”, line 43, in handle
return frappe.handler.handle()
File “/home/myme/frappe-bench/apps/frappe/frappe/handler.py”, line 66, in handle
execute_cmd(cmd)
File “/home/myme/frappe-bench/apps/frappe/frappe/handler.py”, line 89, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/myme/frappe-bench/apps/frappe/frappe/init.py”, line 532, in call
return fn(*args, **newargs)
File “/home/myme/frappe-bench/apps/frappe/frappe/templates/pages/print.py”, line 94, in download_pdf
frappe.local.response.filecontent = get_pdf(html)
File “/home/myme/frappe-bench/apps/frappe/frappe/utils/pdf.py”, line 29, in get_pdf
pdfkit.from_string(html, fname, options=options or {})
File “/home/myme/frappe-bench/env/local/lib/python2.7/site-packages/pdfkit/api.py”, line 68, in from_string
return r.to_pdf(output_path)
File “/home/myme/frappe-bench/env/local/lib/python2.7/site-packages/pdfkit/pdfkit.py”, line 119, 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 1. error:
Unknown long argument --background

Thanks
Bobby

Did you install wkhtmltopdf from the repositories or from http://wkhtmltopdf.org/downloads.html

Did it work before?

i installed from apt-get install wkhtmltopdf , is it required to installed it manually ?

Yes, the one in repositories would be an old and incompatible version

ill try it…thanksss

Remove existing installation:

sudo apt-get remove --purge wkhtmltopdf

Download wkhtmltopdf patched with qt using below command

sudo wget -P Downloads http://download.gna.org/wkhtmltopdf/0.12/0.12.1/wkhtmltox-0.12.1_linux-trusty-amd64.deb

Here, replace “trusty” with your OS name and if 64 bit only then keep “amd64” like that , otherwise change it to “i386” and down load the deb file.

After that execute the following commands,

cd ~/Downloads
sudo dpkg -i wkhtmltox-0.12.1_linux-trusty-amd64.deb

Now, check wkhtmltopdf version with below command,

wkhtmltopdf -V

Now you are able to download pdf.

2 Likes