When I click print on a Purchase Order, the preview renders as it should, with both standard and customized formats. When emailed or when PDF is clicked , the Supplier Supplier, Address, Date and Date req’d fileds are all left justified, as is the Total and Grand total. The Items table seems ok.
Edit: When Print is clicked to print to file, the resulting saved PDF renders correctly.
Happens on Sales Orders too, with or without letterhead.
ERPNext: v10.1.4 (master)
Frappe Framework: v10.1.1 (master)
Ubuntu 14.04 in a VM.
A search on ‘pdf layout’ found for eg this that may help in your case Wkhtmltopdf layout error
Thanks for the link, and for the search. I have a ERPNext: v10.1.18 (master), Frappe Framework: v10.1.16 (master) vm and I am trying to replicate the problem with ERPNext: v10.0.19 (master)
Frappe Framework: v10.0.20 (master)on. So far the PDF’s are rendering properly on that earlier version.
I have diffed the frappe-bench/apps/frappe/frappe/utils/pdf.py on both, no result
libssl1.0-dev is no available for either, libssl-dev is installed on both
firewall rules are identical
wkhtmltopdf is not installed on either
wkhtmltox/now is installed on both.
Trying frappe.throw(html) after line 12 , as suggested. Not sure where the file gets written…
The html will be in the source code of the error message shown when you create a pdf. Run this manually through wkhtmltopdf on the server and you should find more clues. Which distro are you using?
Ubuntu 14.04.5 LTS (in a VBox)
I need to know the path to the folder.
Which folder? Copy & paste the html content into a file (let’s call it test.html) in any folder, e.g. your home folder on the server. Then run it there. wkhtmltopdf is globally available once installed, path does not matter…
wkhtmltopdf test.html test.pdf
Loading pages (1/6)
Warning: Failed to load file:///assets/frappe/css/bootstrap.css (ignore)
Warning: Failed to load file:///assets/frappe/css/font-awesome.css (ignore)
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
I get the same output on the instance without the problem.
Both the.css files are fount in ./frappe-bench/apps/frappe/frappe/public/css/ , on both instances- the one with the problem , and the one without.
These paths will not resolve to the required file. They should be in a http(s) format, then they would work.
Please check your “host_name” configuration in ./sites/site1.local/site_config.json and re-try.
One thing I found, that I should have seen is that the .html that is produced when clicking the print icon , then full page , then saving has the alignment problem, and the pdf from the wkhtmltopdf does as well.
The config.json on the instance with the problem:
And the one that does not:
I’m not sure where the encryption key comes from, or if it is the source of the problem?
Again, my thanks.
Update: I downloaded the site from the non working instance and restored it to the one that did not have the problem. Now when I click the PDF icon after the print icon on a form, it renders correctly. However
When I went to email the form , I could not as the encryption for the email domain in the site_config.json did not agree. I deleted the email account, and the email domain and recreated them. Now I can email - and although clicking print icon, PDF renders ok, the PDFs attached to the email have the justification problem. No errors are being produced in the log.
@lasalesi i do not have a “host_name” in the sites/erpnext.vm/site_config.json
I’ve found that if logged into localhost:8080 , the PDF button reneders correctly.
If logged into 192.168.1.xxx:8080 , from the lan or from the Virtualbox host. The alignment problem occurs.
PDF’s attached to emails sent when logged in either way have alignment problem.
I had the problem, and I set the host_name and It worked… Thank you.
Setting the host_name to the ip of the virtualbox machine in site_config.json did the trick! Thanks to all who helped. This thread was hepful as well, I wish I had seen it sooner.
while the IP address solution may work to get the pdfs to render properly, you will most likely need to use FQDN that the end user will have access to (if you want them to be able to view the document in a browser). I fiddled with the host_name setting myself to get my image working (hosted on our domains web server), but couldn’t figure out why the pdf layout was still broken (i thought it was a bug, and people were just dealing with it). After a lot of struggle, i realized that while the image could load, the CSS could not, as the hostname wasn’t resoling properly on the erpnext server. I’ll give my emample, in case it helps anyone else.
i run erpnext in a container, on port 80
i run another container that handles ngninx and letsencrypt.
i updated hosts file so erp. example. org pointed to erpnext server, but was using https (as it’s correct), but since this server only listens http on port 80, CSS wouldn’t work.
i moved my server back to an internal hostname erp. int. example. org, and then updated the hosts file on the erpnext server so that erp. example. org has IP of my nginx container. this way i can specify host_name as https:// erp. example. org, and i get properly CSSd pdf files, AND working links in my emails. i hope this doesn’t take the rest of you so long!
EDIT: spaced out my domain names, as this is my first post, and i’m limited to 2 “links”
I had the same problem. Solved by adding site_config.json file
I checked on my /etc/resolv.conf was not pointing to my DNS server. After I modified it and reloaded my network, it worked!