Error While PDF Generation

@NCP
Server Error
Traceback (most recent call last):
File “apps/frappe/frappe/app.py”, line 110, in application
response = frappe.api.handle(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/api/init.py”, line 49, in handle
data = endpoint(**arguments)
^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/api/v1.py”, line 36, in handle_rpc_call
return frappe.handler.handle()
^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/handler.py”, line 49, 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 1716, in call
return fn(*args, **newargs)
^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/utils/typing_validations.py”, line 31, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/utils/print_format.py”, line 130, in download_pdf
pdf_file = frappe.get_print(
^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/init.py”, line 2132, in get_print
return get_pdf(html, options=pdf_options, output=output) if as_pdf else html
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/utils/pdf.py”, line 89, 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 158, in handle_error
raise IOError(“wkhtmltopdf exited with non-zero code {0}. error:\n{1}”.format(exit_code, error_msg))
OSError: wkhtmltopdf exited with non-zero code 127. error:
/usr/local/bin/wkhtmltopdf: error while loading shared libraries: libssl.so.1.1:
Getting this error while generating the pdf in servers

@amreen Please Update your wkhtmltopdf library from this and then try it

i want to install in ubuntu 22 and while i am running the second command i am getting this

@amreen Please run this command in going into your frappe bench and first start environment

Hi amreen

You have downloaded the Debian bullseye version … and you are using the command for ubuntu deb !!

@Meet After run those commands, we are getting another error.
wkhtmltopdf version is wkhtmltopdf 0.12.6.1 (with patched qt)

Server Error
Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 49, 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 1716, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/print_format.py", line 130, in download_pdf
    pdf_file = frappe.get_print(
               ^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 2132, in get_print
    return get_pdf(html, options=pdf_options, output=output) if as_pdf else html
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/pdf.py", line 89, 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: SslHandshakeFailedError```

@Kiranmai Please add the local host in the site_config.json file in your site folder

@Meet I added, but still same issue is coming.

Server Error
Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 49, 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 1716, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/print_format.py", line 130, in download_pdf
    pdf_file = frappe.get_print(
               ^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 2132, in get_print
    return get_pdf(html, options=pdf_options, output=output) if as_pdf else html
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/pdf.py", line 89, 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: SslHandshakeFailedError

@amreen check this OSError: wkhtmltopdf reported an error: Exit with code 1 due to network error: SslHandshakeFailedError

set this record to {site}/site_config.json

if use local environment then add your local host ip

"host_name": "http://127.0.0.1:8000",

Then it’s worked!

2 Likes

@Meet I did like this and its worked, but im not getting correct format in pdf!!

this is my site_config.json

{
 "db_name": "dffsdcdc",
 "db_password": "dsffdQ",
 "db_type": "mariadb",
 "developer_mode": 1,
 "host_name":"http://127.0.0.1:8000",
 "encryption_key": "dfhgjhgfgdfsdcs=",
 "user_type_doctype_limit": {
  "employee_self_service": 40
 }
}

My problem is : i need like below image.

but im getting like this.

in print it is working! in pdf only im getting like this!

@Kiranmai Please check your html code it is html code error and css error not working css in your pdf

@Meet But, that is working in print !! How it should happen if that is a css error???
Thank you @Meet !!

1 Like