Wkhtmltopdf error ERPNext V7

Hello!
i have install ERPNext V7 then following guide to install Installing wkhtmltopdf · JazzCore/python-pdfkit Wiki · GitHub
apt-get install wkhtmltopdf
but it seem tobe doesn’t work, i have try many way in the forum similar but it didn’t work too.
anyone know how to fixed this problems? plz help.

frappe.core.doctype.communication.email.sendmail

Traceback (most recent call last):
      File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 387, in sendmail
        recipients=recipients, cc=cc)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 179, in _notify
        _notify(self, print_html, print_format, attachments, recipients, cc)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 121, in _notify
        prepare_to_notify(doc, print_html, print_format, attachments)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 220, in prepare_to_notify
        print_format=print_format, html=print_html))
      File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1174, 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 1157, 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.
1 Like

Looks like you are using wkhtmltopdf version with unpatched Qt.
What does wkhtmltopdf --version show?

Also please use “preformatted text” format for the logs.

@Le_Ba_Chau

You may find this useful:

Which leads to this article:

Keep in mind that the last 4 commands given in the instructions in the link are for Ubuntu 32bit exclusively. If you are using Ubuntu 64bit they will be different. He kind of says that in the instructions, but it’s easy not to read the instructions when you have commands right in front of you. :slight_smile:

1 Like

here is my currently version wkhtmltopdf 0.12.2.4

1 Like

This is like blaming somebody for wrong cake when you focused on ingredients only :smiley:
But yeah - this is for 64 bits - I rarely see 32 bits on servers btw.

Haha so true. Not blaming the author though, I just know that being a noob myself with Linux there’s so many things to learn that sometimes I just glaze over when someone gives me a quick fix to a problem. :slight_smile:

Looking back at the post it would be pretty foolish to follow those last 4 commands (from 2013) and try to install version 0.9.9 - some mornings though, when nothings working, I would’ve tried without thinking. :rolling_eyes:

I had this exact wkhtmltopdf problem a couple of weeks ago: [V7] Wkhtmltopdf error
When no one replied I did a full wipe and reinstall to solve it.

You’re probably right about not many 32 bit servers around, but Digital Ocean still offers them, and the ERPNext VM I believe is also 32 bit.

1 Like

Sorry i am newbie in ubuntu
so anybody help me plz my ubuntu 16.04 x64
i don’t know how to solve this problems.
event yeap i try to install V 0.9.9 but didn’t work.
so plz help.

1 Like

sudo apt-get remove --purge wkhtmltopdf
sudo apt-get install openssl build-essential xorg libssl-dev

wget http://download.gna.org/wkhtmltopdf/0.12/0.12.3/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
tar xvzf wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
cd wkhtmltox-0.12.3_linux-generic-amd64
sudo chown root:root wkhtmltox
sudo cp wkhtmltox /usr/local/bin/wkhtmltopdf

Try this commands, blind shot. Not gonna harm though :wink:

1 Like

hello @Marcin_Walkow!
i did all things like this
493 sudo apt-get purge wkhtmltopdf
494 sudo apt-get purge --auto-remove wkhtmltopdf
496 apt-get update -y
497 apt-get upgrade -y
542 wget http://download.gna.org/wkhtmltopdf/0.12/0.12.3/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
549 tar xvfJ wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
558 sudo chown root:root wkhtmltox
559 sudo cp wkhtmltox /usr/local/bin/wkhtmltopdf
cp: omitting directory ‘wkhtmltox’
571 cd /usr/local/bin
-rwxr-xr-x 1 root root 3954 Jul 24 22:12 ansible
-rwxr-xr-x 1 root root 3954 Jul 24 22:12 ansible-doc
-rwxr-xr-x 1 root root 3954 Jul 24 22:12 ansible-galaxy
-rwxr-xr-x 1 root root 3954 Jul 24 22:12 ansible-playbook
-rwxr-xr-x 1 root root 3954 Jul 24 22:12 ansible-pull
-rwxr-xr-x 1 root root 3954 Jul 24 22:12 ansible-vault
-rwxr-xr-x 1 root root 270 Jul 24 22:19 bench
-rwxr-xr-x 1 root root 232 Jul 24 22:11 easy_install
-rwxr-xr-x 1 root root 232 Jul 24 22:11 easy_install-2.7
-rwxr-xr-x 1 root root 8218920 Aug 2 07:07 wkhtmltopdf

Then try print with google i can see nothing

574 wkhtmltopdf http://google.com google.pdf
ls -al
drwx------ 3 root root 4096 Aug 1 08:19 .config
-rw-r–r-- 1 root root 1524722 May 21 19:30 get-pip.py
-rw-r–r-- 1 root root 33 Aug 2 03:05 .gitconfig
-rw-r–r-- 1 root root 8029 Jul 24 22:10 install.py
-rw-r–r-- 1 root root 655 Jun 24 11:44 .profile
drwx------ 2 root root 4096 Jul 24 20:51 .ssh
-rw------- 1 root root 7599 Aug 2 03:28 .viminfo
-rw-r–r-- 1 root root 263 Aug 4 00:02 .wget-hsts
drwxr-xr-x 6 root root 4096 Jan 20 2016 wkhtmltox
-rw-r–r-- 1 root root 14531204 Jan 20 2016 wkhtmltox-0.12.3_linux-generic-amd64.tar.xz

when i come back to sent email with attach pdf and have an error like this

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py”, line 387, in sendmail
recipients=recipients, cc=cc)
File “/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py”, line 179, in _notify
_notify(self, print_html, print_format, attachments, recipients, cc)
File “/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py”, line 121, in _notify
prepare_to_notify(doc, print_html, print_format, attachments)
File “/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py”, line 220, in prepare_to_notify
print_format=print_format, html=print_html))
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1174, 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 1157, 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 127. error:

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

Wow it work now :slight_smile: thank you @Dadaso_Zanzane :slight_smile:

Steps for install 0.12.3 on Ubuntu 16.04.

Because I wasted way too much time tracking this down, here is for others stumbling on this:

cd ~
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.3/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
tar vxf wkhtmltox-0.12.3_linux-generic-amd64.tar.xz 
cp wkhtmltox/bin/wk* /usr/local/bin/

And you can confirm with:

$ wkhtmltopdf --version
wkhtmltopdf 0.12.3 (with patched qt)

Btw, I chose 0.12.3 instead of 0.12.4 because of a strange page sizing issue, discussed here:

https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3226

4 Likes

Thanks Works like a charm