Add page number to footer custom print format

Hello i have created a custom print format for pick list, the print view gives the correct page number but the pdf view gives incorrect page number when the document has more than one page.See below screenshots

Webview showing correct page number

Then pdf view showing incorrect page number and formatting issue

So let’s see the code generating this page of

{% macro below_items(topage, page) -%}
    <div class="print-footer">
       {{ _("Page {0} of {1}").format(page, topage)}}
{%- endmacro %}


@media print {
    div.print-footer {
        display: block;
        position: fixed;
        bottom: 0;

What could be causing this unexpected behavior, please any help would be much appreciated.

Hi. I’m trying to work with page number in my print formats. Did you resolve your issue? How did you get the current page number and the final page number?