Add footer to the bottom of the last print page

Hi everyone,
I am using a custom print format, and if we have multiple pages, I only want the footer to appear at the bottom of the last page.
When I use code below the footer appears on every page

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

and if I write the footer directly it appears right after the content and there is an empty area after it.
Thank you all

Can you try this, remove the footer from the letter head in use and add it as a custom html at the bottom of the print format.

thank you for your reply,
I tried that but the footer doesn’t show up at the bottom of the page and there is a blank area after it

Can you try setting position absolute within the html?

Not sure of it will work from within the print format, works with footer and header though

I tried that too,
The problem is if I give it

bottom:0;

when html page is rendered the footer will show up at the end of the html page but when it is converted to pdf whole page will divided into multiple A4 pages, that is why the footer doesn’t appear at the bottom of the last page.

I used the code below from this question to solve the problem

<div id=“footer-html” class=“visible-pdf”>
<script>
window.onload = function() {
var vars = {};
var x = document.location.search.substring(1).split(‘&’);
for (var i in x) {
var z = x[i].split(‘=’, 2);
vars[z[0]] = unescape(z[1]);
}
//if current page number == last page number
if (vars[‘page’] == vars[‘topage’]) {
document.querySelectorAll(‘.extra’)[0].innerHTML = ‘’; //footer content
}
};
</script>
<div class=“extra”>
</div>

3 Likes

Where do you put that code?

I put it in the html section of the print format after enabling custom format