Wkhtmltopdf bug

hi Guys i just re Installed “wkhtmltopdf” , then i get this error
while i try to print a document from the desk i get this error

Traceback (most recent call last):
  File "/home/azahra-erp/frappe-bench/apps/frappe/frappe/utils/pdf.py", line 25, in get_pdf
    filedata = pdfkit.from_string(html, False, options=options or {})
  File "/home/azahra-erp/frappe-bench/env/src/pdfkit/pdfkit/api.py", line 68, in from_string
    return r.to_pdf(output_path)
  File "/home/azahra-erp/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")))
OSError: wkhtmltopdf exited with non-zero code -6. error:
The switch --footer-html, 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 --print-media-type, is not support using unpatched qt, and will be ignored.QXcbConnection: Could not connect to display 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/azahra-erp/frappe-bench/apps/frappe/frappe/app.py", line 60, in application
    response = frappe.api.handle()
  File "/home/azahra-erp/frappe-bench/apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "/home/azahra-erp/frappe-bench/apps/frappe/frappe/handler.py", line 21, in handle
    data = execute_cmd(cmd)
  File "/home/azahra-erp/frappe-bench/apps/frappe/frappe/handler.py", line 56, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/azahra-erp/frappe-bench/apps/frappe/frappe/__init__.py", line 1036, in call
    return fn(*args, **newargs)
  File "/home/azahra-erp/frappe-bench/apps/frappe/frappe/utils/print_format.py", line 91, in download_pdf
    frappe.local.response.filecontent = get_pdf(html)
  File "/home/azahra-erp/frappe-bench/apps/frappe/frappe/utils/pdf.py", line 32, in get_pdf
    if ("ContentNotFoundError" in e.message
AttributeError: 'OSError' object has no attribute 'message'

It might be helpful to say the operating environment, version of ERPNext and version of wkhtmltopdf that was installed. Why did you install wkhtmltopdf? Was there a tutorial that you were following?

there was no tutorial , i just re installed it because i were have a problem in Download Table as a PDF so i try to reinstall it . i recognize i miss Arguments from this package related to the Frappe framework

I might try bench setup requirements , then bench update

Thank you , i will try it and told you

You should install the version of wkhtmltopdf with the QT patch.

hi @crafter thank you for helping . but the problem here the Frappe miss arguments from wkhtmltopdf not in it`s version or any thing else . so i want to know a way enable frappe to see wkhtmltopdf to avoid this error.

It says in the error message that it requires the version with the Qt patch.

okay thanks i `ll try it and told you

What does wkhtmltopdf -V return?

@AlinYellow this should return something like wkhtmltopdf 0.12.5 (with patched qt). Else you should uninstall this package and run bench install wkhtmltopdfwhich installs it for you.

5 Likes

i used " bench install wkhtmltopdf " , it didn`t work .

Maybe try this :
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb
&& dpkg -i wkhtmltox_0.12.5-1.stretch_amd64.deb && rm wkhtmltox_0.12.5-1.stretch_amd64.deb

Like in this script https://github.com/frappe/frappe_docker/blob/develop/build/bench/Dockerfile

PS : be sure to uninstall other versions with something like apt remove wkhtmltpodf

Sincerely yours,
Martin

1 Like

The problem you posted in your screen grab is related to issues with ansible.

This had been posted about many, many times. Perhaps use the search to find a solution to the ansible issue.

1 Like

worked for me

please, for the future paste shell error messages as text, not screenshots. It’s just better to work with for anyone else (incl. the people who are going to help with a problem)

2 Likes