Printing page number in the print format

I want to add page number in the footer in the format of “Page 1 of 3” or else “Page 2”, “Page 3”

Tried this, but not working.

<div class="print-format-footer">
    <p id="pagenum"><strong>{{ _("Page {0} of {1}").format('<span class="page"></span>', '<span class="topage"></span>') }}</strong>
     </p>

Hi @nirmal2010,

Page numbers will only show in PDF, not in print or full-page print.

Reference:

Thank You!

4 Likes

Thanks a lot @NCP for this code. Is there any possibility to print the page number?

Maybe not, but you can try.

Thank you

Hi @nirmal2010 Any Success on printing page number in print(full page print) ?

No @Sarah

I didn’t get a solution for this.

Hi guys,

This worked for me (in wkhtmltopdf not chrome pdf generator). Put it right at the end on the footer: -

<h1 style="text-align: center">Put your HTML here</h1>


{% if print_settings.repeat_header_footer %}
<div id="footer-html" class="visible-pdf">
    <p class="text-center small page-number visible-pdf">
        {{ _("Page {0} of {1}").format('<span class="page"></span>','<span class="topage"></span>') }}
    </p>
</div>
{% endif %}

A better alternative is Betterprint-specific Jinja examples | Frappe Betterprint Docs