Header-Footer issue with Custom print format

Issues faced:

  1. Letterhead does not repeat on every page of the pdf.
  2. class ‘visible-pdf’ does not work in custom print formats?
  3. When tried without using the class ‘visible-pdf’, the footer does not appear at the bottom. Instead, it appears in the body(just after the content end).

Approaches tried:
1. basic

<div class="row">
         <div class="col-xs-12">
               {{ letter_head }}
         </div>
</div>

<div id="footer-html" class="visible-pdf">
    {% if not no_letterhead and footer %}
         <div class="letter-head-footer">
               {{ footer }}
         </div>
    {% endif %}
</div>

2. Using standard.html format

<div class="row">
     <div {% if print_settings.repeat_header_footer %} id="header-html" class="hidden-pdf" {% endif %}>
				{{ letter_head }}
      </div>
</div>

{% if print_settings.repeat_header_footer %}
	<div id="footer-html" class="visible-pdf">
		{% if not no_letterhead and footer %}
			<div class="letter-head-footer">
				{{ footer }}
			</div>
		{% endif %}
	</div>	
{% endif %}

3. Using Frappe print setting explicitly

{% for page in layout %}
<div {% if (frappe.get_doc("Print Settings").repeat_header_footer) %} id="header-html" class="hidden-pdf" 	 {% endif %} > 
	<div class="col-xs-12">
		{{ letter_head }}
	</div>
</div>


{% if (frappe.get_doc("Print Settings").repeat_header_footer) %}
	<div id="footer-html">
		{% if not no_letterhead and footer %}
	 <div class="letter-head-footer">
			{{ footer }}
	  </div>
		{% endif %}
	  </div>
{% endif %}
{% endfor %}
1 Like

Hi,
In my custom print format I use

<div id="header-html">
{% if doc.letter_head %}
	<div class="letter-head" style="margin-top: -20px !important;">
		{{ frappe.render_template(frappe.db.get_value("Letter Head", doc.letter_head, "content"), {"doc": doc}) }}
	</div>
{% endif %}
</div>

and I added footer to the end of my print format.

2 Likes

I tried this code in my custom print format. It is still not working.
Also, letterhead and footer are not repeating on every page of the pdf.
Which version you’re currently using?

Hi,
I use
ERPNext: v10.0.17 (master)
Frappe Framework: v10.0.16 (master)
Sorry but have you set “Repeat Header and Footer in PDF” in the Print Settings?

I have tried using all these options. None of them have worked for me in order to get the footer at the bottom and repeat it on every page.

    {% if not no_letterhead and footer %}
    <div class="letter-head-footer">
        {{ footer }}
    </div>
    {% endif %}
    <p class="text-right small page-number visible-pdf">
        {{ _("Page {0} of {1}").format('<span class="page"></span>', '<span class="topage"></span>') }}
    </p>
</div>

This is working

1 Like