Header, Footer in PDF in Ver 13

Hi,

My developer is not able to figure out why Header and Footer is not appearing in the PDF in the ver 13 Production instance.

Can somebody please help? Have things changed? Is there anything we are missing?

Thanks

Jay

A couple of things to look at:

Check in the Letter Head list that the letter head is enabled. When previewing using the print icon, check print settings.

All settings are appropriate. But the Header just appears on the first page and the footer does not appear at all.

Thanks

Jay

On print setting
Step 1: uncheck Repeat Header and Footer in PDF field
Step 2: Save & Clear Cache
Step 3: check Repeat Header and Footer in PDF field
Step 4: Save & Clear Cache

I’m still having this issue, does anyone else?

And if any could test on this also…

Hi Jay

I also faced this issue in last weak, even everything is correct but footer was not appearing in pdf. I created a sample custom print format and after that this issue automatically resolved. Make a custom print format add the following code after that other print formats header or footer is working fine.

     <div class="col-xs-12">

           {{ letter_head }}

     </div>
{% if not no_letterhead and footer %}
{{ footer }}
{% endif %}

Kindly let me know if this works for you.

Best Regards
Ranbir

1 Like

Facing same issue here

I am having the same issue where the Header and Footer only show on the 1st page of the pdf.

The issue appeared after we updated to frappe and erpnext about a month ago. We had not updated the instance for a while before that.

We just updated to ERPNext: v13.16.1 (version-13) and Frappe Framework: v13.16.0 (version-13), and the issue is still present.

We already tried fiddling with the print settings (turning off and then back on to repeat on every page). My programmer seems to think it’s a system bug that needs to be resolved by Frappe.

Can anyone confirm if it’s just us having this issue, or is it affecting everyone else on this version?

Hello @JayRam were you able to find a solution to this problem? We are having the same issue and can’t figure out how to fix it.

We were able to fix this issue by adding a page break in the sales invoice after specified number of lines.

Without the page break, the sales invoice items table was overflowing onto the footer of the first page and both header and footer of the consequent pages.

Also, it might be worthwhile to check if you’re using the latest version of wkhtmltopdf on the server. (https://wkhtmltopdf.org/downloads.html)

Thank you @Sambhav_Patni we’ll give this a try.

The link indicates the current stable series is 0.12.6 , which was released on June 11, 2020. Checking our server looks like we have version 12.5 (with patched qt) - whatever that means.

erpnext@erpnext:~$ wkhtmltopdf --version
wkhtmltopdf 0.12.5 (with patched qt)

What would be the correct way to upgrade this?

I’m having this same issue where the header and footer won’t print on the pdf even though they show up in html print view.

I’ve tried mutliple permutations of host_name":"http://mywebsite in the config file.
I’ve installed libssl-dev

Any other suggestions?

I wrestled hard with this one, but upgrading to the latest version of wkhtmltopdf (0.12.6) with the qt patches fixed it this problem for me. Here is the process I followed:

I used wget to download the latest version of it from here: (in my case the amd64 debian version)
https://wkhtmltopdf.org/downloads.html

And then I unpackaged it. I had to install a few dependencies (xfonts-75dpi), but this fixed it so that now running this from command line:
sudo wkhtmltopdf -V
Results in this:
wkhtmltopdf 0.12.6 (with patched qt)

I am running ERPNEXT v 13 on a google hosted debian vm. The problem is that the version of wkhtmltopdf that was installed on my vm was not compiled with the qt patches and could therefore was not able to build a pdf with the header or footer options. (You can read the FAQ on the download page I linked above for more info.)

Thanks!

Just add this after html content

{% if print_settings.repeat_header_footer %}
	<div id="footer-html" class="print-footer">
		{% if not no_letterhead and footer %}
            <div style="position: relative;">
                <div class="letter-head-footer">
			        {{ footer }}
		 </div>
            </div>
		{% endif %}
		<p class="text-right small page-number visible-pdf" style="font-family: Cairo;">
			{{ _("الصفحة {0} من {1}").format('<span class="page" style="color:#2166b1;"></span>', '<span class="topage" style="color:#2166b1;"></span>&nbsp;&nbsp;') }}
		</p>
	</div>
{% endif %}

Add the class of “footer-html” as following and remove class ’ visible-pdf’ from the div
<div id="footer-html" class="print-footer">
and in css add:
@media print {
.print-footer {
position: fixed;
bottom: 0;
}
}

Thank you @WHP-Jeff

If I already have installed version 0.12.5, do I need to uninstall it first prior to installing 0.12.6? If so, what exact steps should be followed to uninstall? Or should I simply install 0.12.6 on top of 0.12.5 without uninstalling the old version first?

How will I know if I have to install dependencies like you did?

In my linux system (Ubuntu 20.04) wkhtmltopdf was installed with erpnext and not on its own, so I’m unable to uninstall using sudo apt-get remove wkhtmltopdf --purge.

Typing locate wkhtmltopdf shows:

erpnext@erpnext-server:~$ locate wkhtmltopdf
/home/erpnext/.bench/bench/playbooks/roles/wkhtmltopdf
/home/erpnext/.bench/bench/playbooks/roles/wkhtmltopdf/tasks
/home/erpnext/.bench/bench/playbooks/roles/wkhtmltopdf/tasks/main.yml
/usr/local/bin/wkhtmltopdf
/usr/local/share/man/man1/wkhtmltopdf.1.gz

When installing the new version, which directory should I use to download with wget, and what specific steps should be followed to install?

Thank you very much for your help.

I was able to upgrade wkhtmltopdf to version 0.12.6 (with patched qt) by simply following this.

The bad news is that it did not fix my issue; when I print the Sales Orders etc to pdf, the company logo (letterhead) only appears on the first page and not on the following ones. This only happens if I access the webpage from the internet (typing erpnext.mydomain.com) whereas the logo issue does not happen if I access the webpage from inside the LAN where the web server is located i.e. http://192.168.x.x.

I have not installed SSL/TLS on the ERPNext server, instead I rely on my reverse proxy which has the SSL/TLS Certificate installed for the subdomain.

My next step will be to enable https on the erpnext server to see if it solves the issue.

I have been able to solve the issue by simply opening port 80 and creating a port forward rule on the security gateway / router. After doing this, I am able to print pdf’s with the company logo on all pages.