Install of wkhtmltopdf

541 views
Skip to first unread message

Ulrik Tuemand

unread,
Aug 15, 2014, 7:33:53 AM8/15/14
to erpnext-dev...@googlegroups.com
Hey Guys,

I've tried to install wkhtmltopdf, so i would be able to send sales orders etc in pdf's.

However im facing some troubles.

If i use wkhtmltopdf straight from as a cli command it works, but when trying from erpnext i face the following error.

can someone help me out?

Traceback (innermost last):
  File "/home/ulrik/frappe-bench/apps/frappe/frappe/app.py", line 52, in application
    response = frappe.api.handle()
  File "/home/ulrik/frappe-bench/apps/frappe/frappe/api.py", line 42, in handle
    return frappe.handler.handle()
  File "/home/ulrik/frappe-bench/apps/frappe/frappe/handler.py", line 66, in handle
    execute_cmd(cmd)
  File "/home/ulrik/frappe-bench/apps/frappe/frappe/handler.py", line 89, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/home/ulrik/frappe-bench/apps/frappe/frappe/__init__.py", line 526, in call
    return fn(*args, **newargs)
  File "/home/ulrik/frappe-bench/apps/frappe/frappe/templates/pages/print.py", line 93, in download_pdf
    frappe.local.response.filecontent = get_pdf(html)
  File "/home/ulrik/frappe-bench/apps/frappe/frappe/utils/pdf.py", line 28, in get_pdf
    pdfkit.from_string(html, fname, options=options or {})
  File "/home/ulrik/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/ulrik/frappe-bench/env/local/lib/python2.7/site-packages/pdfkit/pdfkit.py", line 131, in to_pdf
    ' '.join(args))
 IOError: Command failed: /usr/bin/wkhtmltopdf --margin-top 15mm --margin-right 15mm --page-size A4 --encoding UTF-8 --background --print-media-type --images --margin-left 15mm --no-outline --margin-bottom 15mm - /tmp/d7186958919ad48ba14b96722d0f2378c8dbff211862a8dc3689cf5a.pdf
Check whhtmltopdf output without 'quiet' option

Anand Doshi

unread,
Aug 16, 2014, 4:15:50 AM8/16/14
to erpnext-dev...@googlegroups.com, Anand Doshi
Hi Ulrik,

Go to the record you are trying to print, click on “Preview” from print view, and save the file as HTML.

Then, try running this exact command, with source file as the html file:
/usr/bin/wkhtmltopdf --margin-top 15mm --margin-right 15mm --page-size A4 --encoding UTF-8 --background --print-media-type --images --margin-left 15mm --no-outline --margin-bottom 15mm /path/to/{{ SOURCE FILE }} /tmp/{{ TARGET FILE }}.pdf

-Anand.

Dhaifallah Alwadani

unread,
Aug 16, 2014, 2:04:21 PM8/16/14
to erpnext-dev...@googlegroups.com
Just to add my experience. 
Installing wkhtmltopdf using apt-get is outdated and does not support everything that frappe needs. I think you should download a .deb from their website and manually install it.

Anand Doshi

unread,
Aug 18, 2014, 3:06:36 AM8/18/14
to ERPNext Developer's Forum, Pratik Vyas
Hi Dhaifallah,

Thanks for the heads up! I've updated the readme.md: https://github.com/frappe/bench/blob/master/README.md#manual-install

@Pratik. Debian/Ubuntu has missing wkhtmltopdf installation in setup_frappe.sh.

-Anand.


--
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/f0ac94d1-e6ee-4c9c-aa4c-42d015197729%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages