Issue with wkhtmltopdf

Hello Guys !

I installed Erpnext with a bitnami instence, but Wkhtmltopdf was apparently not inclued.
I followed this Odoo packaged by Bitnami to install the patched version, And now I get this when I want to get a PDF version of a quote:

    Traceback (innermost last):
  File "/opt/bitnami/apps/erpnext/htdocs/frappe-bench/apps/frappe/frappe/app.py", line 63, in application
    response = frappe.api.handle()
  File "/opt/bitnami/apps/erpnext/htdocs/frappe-bench/apps/frappe/frappe/api.py", line 50, in handle
    return frappe.handler.handle()
  File "/opt/bitnami/apps/erpnext/htdocs/frappe-bench/apps/frappe/frappe/handler.py", line 20, in handle
    execute_cmd(cmd)
  File "/opt/bitnami/apps/erpnext/htdocs/frappe-bench/apps/frappe/frappe/handler.py", line 37, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/opt/bitnami/apps/erpnext/htdocs/frappe-bench/apps/frappe/frappe/__init__.py", line 801, in call
    return fn(*args, **newargs)
  File "/opt/bitnami/apps/erpnext/htdocs/frappe-bench/apps/frappe/frappe/templates/pages/print.py", line 150, in download_pdf
    frappe.local.response.filecontent = get_pdf(html)
  File "/opt/bitnami/apps/erpnext/htdocs/frappe-bench/apps/frappe/frappe/utils/pdf.py", line 16, in get_pdf
    pdfkit.from_string(html, fname, options=options or {})
  File "/opt/bitnami/apps/erpnext/htdocs/frappe-bench/env/lib/python2.7/site-packages/pdfkit/api.py", line 68, in from_string
    return r.to_pdf(output_path)
  File "/opt/bitnami/apps/erpnext/htdocs/frappe-bench/env/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:
--no-outline specified in incorrect location

I first tried to install the depedencies with apt-get, and erpnext was complaining to the fact the package was not patched.

Any ideas ?

@antoniogini maybe the version that do you is using is wrong! I was with the same problem in a old server

I made this commands to solve the issue

sudo apt-get install python-dev python-setuptools build-essential python-mysqldb git ntp vim screen htop  libxslt1.1 libxslt1-dev redis-server libssl-dev libcrypto++-dev postfix nginx supervisor python-pip fontconfig libxrender1 libxext6 xfonts-75dpi xfonts-base libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev libffi-dev nodejs -y

wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-precise-i386.deb
dpkg -i wkhtmltox-0.12.2.1_linux-precise-i386.deb

Take a look in to the arch of your server, if this is not i386, replace by amd64 in the package names

1 Like

Hi ! Thank you for your aswer.

I already tried like 3 versions, the same issue every single time …

@antonioginim which OS and version do you is using?

Debian GNU/Linux 8.3 (jessie) ^^

I have the same problem is there already a fix?

I am also getting same error.

Traceback (innermost last):
  File "/home/erpnext/erpnext/test-frappe/frappe-bench/apps/frappe/frappe/app.py", line 60, in application
    response = frappe.api.handle()
  File "/home/erpnext/erpnext/test-frappe/frappe-bench/apps/frappe/frappe/api.py", line 50, in handle
    return frappe.handler.handle()
  File "/home/erpnext/erpnext/test-frappe/frappe-bench/apps/frappe/frappe/handler.py", line 19, in handle
    execute_cmd(cmd)
  File "/home/erpnext/erpnext/test-frappe/frappe-bench/apps/frappe/frappe/handler.py", line 36, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/home/erpnext/erpnext/test-frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 806, in call
    return fn(*args, **newargs)
  File "/home/erpnext/erpnext/test-frappe/frappe-bench/apps/frappe/frappe/templates/pages/print.py", line 182, in download_pdf
    frappe.local.response.filecontent = get_pdf(html)
  File "/home/erpnext/erpnext/test-frappe/frappe-bench/apps/frappe/frappe/utils/pdf.py", line 16, in get_pdf
    pdfkit.from_string(html, fname, options=options or {})
  File "/home/erpnext/erpnext/test-frappe/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/erpnext/erpnext/test-frappe/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:
--no-outline specified in incorrect location

Name:
  wkhtmltopdf 0.12.2.1 (with patched qt)

Synopsis:
  wkhtmltopdf [GLOBAL OPTION]... [OBJECT]...

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

1 Like

Just wanted to find out what is the latest version of wkhtmltopdf, i currently have version 0.12.4 installed on my machine, shall i replace with a latter version??

0.12.5 with patched Qt is recommended.

1 Like

As suggested by @rmeyer, i recommend you in the case of ERPNext 12, a specific version of wkhtmltopdf is required, 0.12.5 with patched Qt.

To install wkhtmltopdf , start by switching to a suitable directory to download the package, in this case /tmp :

cd /tmp

Download the appropriate wkhtmltopdf version and package for Ubuntu 18.04 from the project’s page:

wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb

Now install the package using the dpkg tool:

sudo dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb

Next, copy all relevant executables to your /usr/bin/ directory:

sudo cp /usr/local/bin/wkhtmlto* /usr/bin/

Once the files are in place, change their permissions to make them executable:

sudo chmod a+x /usr/bin/wk*
3 Likes

Hey @Suresh_Thakor, @rmeyer
Your suggestions fixed my problem.
Thanks