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 %}
2 Likes

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

I have tried this one but not worked
Steps
1.added header and footer in letter head.
2.added your code in custom print format.

But not worked.Is there any suggestions when add your code to custom print format?

Has anyone Found any solution for this ?
I have been stuck on this for a Month Now.

Ironic, that this issue hasn’t been solved yet after 6 years

@osama1998H Totally Agreed,
@NCP @rmehta @nabinhait @avc @michelle

Please Guys Take some action ASAP,

this custom print format page number has become a headache for everyone facing this issue.
we need the page number in the print , it only gives it in the pdf , not in the full page print
we need the solution for this.

Anyone here using any customize Frappe theme?

Are you using print designer? The new one? Ref: GitHub - frappe/print_designer: Visual print designer for Frappe / ERPNext

@michelle Thanks Dear for the prompt response,
We are using ERPNext V13.40.1,
Custom Print format.
Not able to get the page number in the print(full page print, not pdf)

Picture added for reference.