Important Information on wkhtmltopdf for pdf generation in develop branch

We have found a problem in the current develop branch of ERPNext.

The problem was that when you generate a PDF from a print format the CSS styles were not applied when bench is running on supervisor and nginx. The styles are applied to the preview but the generated PDF is broken. This has to do with the PDF generator library wkhtmltopdf.

It was a bit harder to debug because when you run bench in developer mode with bench start or if you don’t have https configured (letsencrypt) this problem doesn’t happen. Thanks to the developer chat on telegram we were able to find the solution.

Solution:

Before updating to the latest develop you have to update your wkhtmltopdf version to 0.12.5. Most of you probably have 0.12.3 or 0.12.4 installed.

GitHub Issue:

4 Likes

Unfortunately the problem doesn’t seem resolved yet. This is an ongoing discussion regarding support for Ubuntu 14.04 and 16.04 now. Will update once resolved.

how do i update?

You can update it by

wget https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox_0.12.5-1.xenial_amd64.deb
sudo dpkg -i wkhtmltox_0.12.5-1.xenial_amd64.deb
sudo apt -f install

I belive that wkhtmltopdf supports some of the html, css codes.
For instance this code in Customize Print Format page doesn’t work for me in v11:

<h3>{{ doc.select_print_heading or "Invoice" }}</h3>
<div class="row">
    <div class="col-md-3 text-right">Customer Name</div>
    <div class="col-md-9">{{ doc.customer_name }}</div>
</div>

But something like this ok for me:

<div class="row section-break">
	<div class="col-xs-6 column-break"></div>
	<div class="col-xs-6 column-break" style="padding-left: 58px; margin-top: -25px;">
		<div class="row">
			<div class="col-xs-6">
			</div>
			<div class="col-xs-6 value">
				{{ doc.get_formatted("posting_date") }}
			</div>
		</div>
	</div>
</div>