Server error when trying to print PDF

Hello. We have two issues. Maybe someone knows how to solve one of these, which would be sufficient for the time being. First, when trying to print invoices, the actual print version looks different than what is shown on screen before. That is, we see the invoice in A4 format, click print, and the preview here looks different than what we saw before. Different on paper also.

Second issue: Trying to navigate around the first issue, we wanted to first print to PDF and then send the PDF to the paper printer. This throws the following server error:

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 95, in application
    response = frappe.api.handle()
               ^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 47, in handle
    data = execute_cmd(cmd)
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1622, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/print_format.py", line 133, in download_pdf
    pdf_file = frappe.get_print(
               ^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 2053, in get_print
    return get_pdf(html, options=pdf_options, output=output)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/pdf.py", line 38, in get_pdf
    filedata = pdfkit.from_string(html, options=options or {}, verbose=True)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pdfkit/api.py", line 75, in from_string
    return r.to_pdf(output_path)
           ^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pdfkit/pdfkit.py", line 201, in to_pdf
    self.handle_error(exit_code, stderr)
  File "env/lib/python3.11/site-packages/pdfkit/pdfkit.py", line 155, in handle_error
    raise IOError('wkhtmltopdf reported an error:\n' + stderr)
OSError: wkhtmltopdf reported an error:
Exit with code 1 due to network error: UnknownNetworkError

I am aware that there are some posts here with similar error snippets, but none the same. If anyone knows how to solve this, an answer would be very much appreciated.

which version do you have?
wkhtmltopdf --version

wkhtmltopdf 0.12.5 (with patched qt). I see there is a newer version available. You think this might be the issue?

The most common source of wkhtmltopdf problems is the version. 12.6.x+ (qt patched) seems to be the most stable

2 Likes