Cannot download pdf invoices

Hi, when using the standard format for sales invoices, and clicking the link “Download PDF” the following url is called:

/api/method/frappe.templates.pages.print.download_pdf?doctype=Sales%20Invoice&name=SINV-000XX&format=Standard&no_letterhead=0

But we receive the following error:

Traceback (innermost last):
  File "/opt/frappe-bench/apps/frappe/frappe/app.py", line 52, in application
    response = frappe.api.handle()
  File "/opt/frappe-bench/apps/frappe/frappe/api.py", line 42, in handle
    return frappe.handler.handle()
  File "/opt/frappe-bench/apps/frappe/frappe/handler.py", line 66, in handle
    execute_cmd(cmd)
  File "/opt/frappe-bench/apps/frappe/frappe/handler.py", line 89, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/opt/frappe-bench/apps/frappe/frappe/__init__.py", line 531, in call
    return fn(*args, **newargs)
  File "/opt/frappe-bench/apps/frappe/frappe/templates/pages/print.py", line 94, in download_pdf
    frappe.local.response.filecontent = get_pdf(html)
  File "/opt/frappe-bench/apps/frappe/frappe/utils/pdf.py", line 28, in get_pdf
    pdfkit.from_string(html, fname, options=options or {})
  File "/opt/frappe-bench/env/local/lib/python2.7/site-packages/pdfkit/api.py", line 68, in from_string
    return r.to_pdf(output_path)
  File "/opt/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/714be61e1cb3c7eb00fc6f288f9d14eb60af7bf2f6fc5a9bbbf2c8e2.pdf
Check whhtmltopdf output without 'quiet' option/opt

What is the output of wkhtmltopdf https://en.wikipedia.org /dev/null?

wkhtmltopdf: cannot connect to X server

try installing xvfb

xvfb installed, still cannot connect to X server…

did you install wkhtmltopdf from the packages on the website or from your distro’s repositories?

from the distro repository… debian

apt-get install wkhtmltopdf

yeah, get rid of it and use one from wkhtmltopdf

OK, we tried again in a fresh CentOS 7 installation, wkhtmltopdf 0.12.1 but still we receive:

wkhtmltopdf: cannot connect to X server

Which X server or other dependencies must be installed in CentOS 7? We tried with the package xorg-x11-server-Xvfb but still the same error.

OK this is what I get
Traceback (innermost last):
File “/home/erpnext/frappe-bench/apps/frappe/frappe/app.py”, line 52, in application
response = frappe.api.handle()
File “/home/erpnext/frappe-bench/apps/frappe/frappe/api.py”, line 42, in handle
return frappe.handler.handle()
File “/home/erpnext/frappe-bench/apps/frappe/frappe/handler.py”, line 66, in handle
execute_cmd(cmd)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/handler.py”, line 89, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/init.py”, line 531, in call
return fn(*args, **newargs)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/templates/pages/print.py”, line 94, in download_pdf
frappe.local.response.filecontent = get_pdf(html)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/utils/pdf.py”, line 28, in get_pdf
pdfkit.from_string(html, fname, options=options or {})
File “/home/erpnext/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/frappe-bench/env/local/lib/python2.7/site-packages/pdfkit/pdfkit.py”, line 109, in to_pdf
raise IOError(‘wkhtmltopdf reported an error:\n’ + stderr.decode(‘utf-8’))
IOError: wkhtmltopdf reported an error:
Loading pages (1/6)
[> ] 0%
[======> ] 10%
[==========> ] 17%
Warning: Failed to load http://erpnext/assets/frappe/css/bootstrap.css (ignore)
Warning: Failed to load http://erpnext/files/scanbech logo.jpg (ignore)
[============================================================] 100%
Counting pages (2/6)
[============================================================] Object 1 of 1
Warning: Received createRequest signal on a disposed ResourceObject’s NetworkAccessManager. This migth be an indication of an iframe taking to long to load.
Warning: Received createRequest signal on a disposed ResourceObject’s NetworkAccessManager. This migth be an indication of an iframe taking to long to load.
Resolving links (4/6)
[============================================================] Object 1 of 1
Loading headers and footers (5/6)
Printing pages (6/6)
[> ] Preparing
[==============================> ] Page 1 of 2
[============================================================] Page 2 of 2
Done
Exit with code 1 due to network error: HostNotFoundError

Output of wkhtmltopdf https://en.wikipedia.org /dev/null
Loading pages (1/6)
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done

bench update --bench
bench set-url-root {sitename} http://{hostname_that_resolves}
1 Like

Which is the site name? I upgraded from version 3 to 4.

Then it will be erpnext