Wkhtmltopdf layout error

Hello everyone,

I have a strange bug with wkhtmltopdf (version 0.12.4 with qt patches)
The HTML layout is good but when I generate PDF the layout is lost

For example when printing a Project

And in PDF I have :

Have you already have this error in your setup ?
How can I resolve this ?

Thanks for your help.



It’s strange, I have installed the wkhtmltopdf from frappe repository and it’s not working.
When I try demo.erpnext.com it’s OK.

What’s the difference between my installation and demo.erpnext.com ?

How can I debug this layout bug ?

@KanchanChauhan perhaps you can advise here, thanks?

1 Like

Hi @jodeq,

there can be different reasons that can lead to this. I would guess that wkhtmltopdf cannot access the references resources (CSS and imgs). This can be caused e.g.

  • by a firewall blocking these intra-zone calls
  • the hostname configuration of ERPNext (see site/site1.local/site_config.json should contain "host_name": "https://www.yourdomain.com",)
  • by a missing libssl1.0-dev (normally missing in Debian 9)

You can also troubleshoot by extracting the html that goes to wkhtmltopdf by temporarily setting a frappe.throw(html) after line 12 of frappe/utils/pdf.py and then running wkhtmltopdf file.html file.pdf on the server (where file.html is a blank html file with the extracted html code from before) and observe the error messages.

Hope this helps.


It was my issue !

Thank you @lasalesi

1 Like