PDF print is broken and Letterhead in PDF not appearing

Hi,

I’ve recently installed v12 in a local server. Everything seems fine [so far], but I’m having trouble generating PDF prints. The PDF format is broken while the preview works just fine.

The preview looks like:

And the PDF looks like this:

All other settings related to printing is okay. What might be causing this? Can anyone enlighten me the solution?

Thanks in advance.

Regards

1 Like

See if these threads are helpful:

https://discuss.erpnext.com/t/pdf-alignment-problem/34425/13

https://discuss.erpnext.com/t/pdf-email-problems-thread/11614

Thanks. I did tried to find a solution and found a thread regarding the host name. I added the hostname in the config file but still the same error.

I will read the discussions again in the morning.

Thanks for your help.

@smino

Thanks man! I found the issue.

The “libssl1.0-dev” was missing. Version was “libssl-dev”.

Thanks everyone.

1 Like

Hi fnrfarid
Please can you share details how did you fix this?

You have to add the hostname in your siteconfig file. Check this Wkhtmltopdf layout error

1 Like

already done this but no luck

Its fixed there was small mistake i added
“host_name”: “https://www.yourdomain.com:portnumber

1 Like

@zahidshuja can you please explain which port number you used , Is it Nginx 80 , 443 or other ?

Same problem, fixed after.
1.- installing libssl1.0-dev (sudo apt-get install -y libssl1.0-dev)
2.- Adding hostname in site_config.json ( “host_name”: “https://www.yourdomain.com",) in my case , no need to add port, because i already have “nginx_port”: 8001 in site_config.json file

Hope this helps

2 Likes

“host_name”: “IP_address_of_the_server:site_port_number” worked for me. Thanks.

Just installing libssl1.0-dev worked after PDF print broke after updating ERPNext.

Thanks. It helped me. In case of SSL based sites also it worked.

I checked on my /etc/resolv.conf and it was not pointing to my DNS server. After I modified it and reloaded my network, it worked!

I am having trouble with the generating pdf in k8s production environment.
The official docker-compose setup run ok though.

Can someone give me some pointer on how to fix the 504 time out error of generating pdf in k8s ?

I have also tried to install libssl-dev apt-get update & apt-get install libssl-dev
and disable all the letter head to make sure that there is no private image but also no luck

logs of the error. I tried to play around with the host_name in site_config but no luck yet

probably need to setup break point in pdf.py and change the href following this suggestion

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 68, in application
    response = frappe.api.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 45, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 83, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1574, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/print_format.py", line 129, in download_pdf
    frappe.local.response.filecontent = get_pdf(html)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/pdf.py", line 38, in get_pdf
    filedata = pdfkit.from_string(html, options=options or {}, verbose=True)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pdfkit/api.py", line 75, in from_string
    return r.to_pdf(output_path)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pdfkit/pdfkit.py", line 201, in to_pdf
    self.handle_error(exit_code, stderr)
  File "/home/frappe/frappe-bench/env/lib/python3.10/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: TimeoutError

can’t even put a break point in :frowning:

"program": "${workspaceFolder}/frappe-bench/apps/frappe/frappe/utils/bench_helper.py",

also gives timeout :frowning: