PDF file generation error

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/pdf.py”, line 38, in get_pdf
filedata = pdfkit.from_string(html, False, options=options or {})
File “/home/frappe/frappe-bench/env/lib/python3.5/site-packages/pdfkit/api.py”, line 72, in from_string
return r.to_pdf(output_path)
File “/home/frappe/frappe-bench/env/lib/python3.5/site-packages/pdfkit/pdfkit.py”, line 156, in to_pdf
raise IOError(‘wkhtmltopdf reported an error:\n’ + stderr)
OSError: wkhtmltopdf reported an error:
QSslSocket: cannot resolve CRYPTO_num_locks
QSslSocket: cannot resolve CRYPTO_set_id_callback
QSslSocket: cannot resolve CRYPTO_set_locking_callback
QSslSocket: cannot resolve sk_free
QSslSocket: cannot resolve sk_num
QSslSocket: cannot resolve sk_pop_free
QSslSocket: cannot resolve sk_value
QSslSocket: cannot resolve SSL_library_init
QSslSocket: cannot resolve SSL_load_error_strings
QSslSocket: cannot resolve SSLv3_client_method
QSslSocket: cannot resolve SSLv23_client_method
QSslSocket: cannot resolve SSLv3_server_method
QSslSocket: cannot resolve SSLv23_server_method
QSslSocket: cannot resolve X509_STORE_CTX_get_chain
QSslSocket: cannot resolve OPENSSL_add_all_algorithms_noconf
QSslSocket: cannot resolve OPENSSL_add_all_algorithms_conf
QSslSocket: cannot resolve SSLeay
QSslSocket: cannot call unresolved function CRYPTO_num_locks
QSslSocket: cannot call unresolved function CRYPTO_set_id_callback
QSslSocket: cannot call unresolved function CRYPTO_set_locking_callback
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function sk_num
Exit with code 1 due to network error: ContentNotFoundError
QSslSocket: cannot call unresolved function CRYPTO_num_locks
QSslSocket: cannot call unresolved function CRYPTO_set_id_callback
QSslSocket: cannot call unresolved function CRYPTO_set_locking_callback

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 62, in application
response = frappe.api.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/api.py”, line 55, in handle
return frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 22, in handle
data = execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 61, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1054, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/print_format.py”, line 92, in download_pdf
frappe.local.response.filecontent = get_pdf(html)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/pdf.py”, line 46, in get_pdf
frappe.throw(_(“PDF generation failed because of broken image links”))
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 377, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’, is_minimizable=is_minimizable)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 356, in msgprint
_raise_exception()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 316, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.ValidationError: PDF generation failed because of broken image links

Install libssl1.0-dev

Make sure image links are proper and working.

Similar issue: wkhtmltopdf throws "QSslSocket: cannot resolve CRYPTO_num_locks" when using a template · Issue #2 · amra/DocumentationAsCode · GitHub
Please go through.

I got the following error trying to export. Solution was to delete all stylesheet links and script tags linking to files that were pointing to non-existing files. (“assets/bootstrap/css/bootstrap.min.css” for example)

Just commenting in case anybody else has the same issue and finds this thread!

    Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/pdf.py", line 39, in get_pdf
    filedata = pdfkit.from_string(html, False, options=options or {})
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pdfkit/api.py", line 72, in from_string
    return r.to_pdf(output_path)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pdfkit/pdfkit.py", line 156, in to_pdf
    raise IOError('wkhtmltopdf reported an error:\n' + stderr)
OSError: wkhtmltopdf reported an error:
Exit with code 1 due to network error: ContentNotFoundError


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 64, in application
    response = frappe.api.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 59, in handle
    return frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 24, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 64, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1064, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/print_format.py", line 92, in download_pdf
    frappe.local.response.filecontent = get_pdf(html)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/pdf.py", line 47, in get_pdf
    frappe.throw(_("PDF generation failed because of broken image links"))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 377, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 356, in msgprint
    _raise_exception()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 316, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.ValidationError: PDF generation failed because of broken image links

might be related to:

I have found, that when the file is not in /files/private/filename.png then I have no problem.

how did you find these and delete them?

I’m running things on docker and this just started yesterday

I have the same problem.
I have no images in my report. Example User Document, goto Print → HTML Preview and then to PDF.
I get

OSError: wkhtmltopdf reported an error:
Exit with code 1 due to network error: ContentNotFoundError

and as following error

frappe.exceptions.ValidationError: PDF-Generierung ist aufgrund fehlerhafter Verknüpfungen für Bilddateien fehlgeschlagen

I have tried all variants of host_name in site.config, but no success.
It is at this time a showstopper, because my app depends very much on the PDF functionality.

I’m very dependant on PDF as well. Switching to Chrome Headless really solved lots of issues for me.

If you are hosted on Frappe Cloud check my fork which supports Frappe Cloud.

Chrome Pros: real WYSIWYG with support to latest css.

Limitations: No Repeating Letterheads & Page Numbering

Limitations can be solved with puppeteer/pyppeteer or in less technical methods like structuring print formats as a table and using pagedjs.

1 Like

Can you tell me your fork repo url?

I can’t find on github

1 Like

I had the same problem,but i sorted it out by going to the server at location
**cd /etc** then i **sudo nano hosts**
then i added this line
127.0.0.1 erp.domain.com
this sorted my issue