Adding page number in report

Hi,

I have created new Custom Reports but I am not able to add page number and change the date format there in report.
It would be highly appreciated if anyone help me in adding page number and changing the date format in my report.

Thanks in Advance,
Tanveer

@tanveer
I hope you are talking about print format not about the report.

See the blow example of Page Number:

{%- macro add_header(page_num, max_pages, doc, letter_head, no_letterhead) -%}
    {% if letter_head and not no_letterhead %}
    <div class="letter-head">{{ letter_head }}</div>
    {% endif %}
    {%- if doc.meta.is_submittable and doc.docstatus==0-%}
    <div "text-center">
    {%- if doc.workflow_state=="Submit" -%}
     <h4 align="center"> {{ _("Approved") }}</h4></div>  
    {%- endif -%}
   {% endif %}
     {%- if doc.meta.is_submittable and doc.docstatus==2-%}
    <div class="alert alert-danger text-center">
        <h4 style="margin: 0px;">{{ _("CANCELLED") }}</h4></div>
    {%- endif -%}
    {% if max_pages > 1 %}
    <p class="text-right">{{ _("Page #{0} of {1}").format(page_num, max_pages) }}</p>
    {% endif %}
{%- endmacro -%}

{{ add_header(0,1,doc,letter_head, no_letterhead) }}

Regards
Ruchin Sharma

1 Like

I have tried this but its not working…:frowning:

@tanveer
In that case I appreciate if you can share your code.

Regards
Ruchin Sharma

I am talking about report only that I have created custom Reports.
I have to add page number while printing that Custom Report.

Hi,

I have created new custom app and inside that I have created new Custom Reports and in that I have to add page number and change the date format there.

Hi @ruchin78,

Can you please guide me where to right this script in order to add page number in print format.
Does adding this script adds page no in all the report that I will print.
As I am new to ERPNext, kindly help me out in solving this.

Thanks,
Tanveer

@tanveer
May you please share your screenshot/code?

Regards
Ruchin Sharma

this is my html file to print the report.
now please tell me that how can I add page no and change the date format in this report.

reagrds,
tanveer

@tanveer
Refer this:
https://discuss.frappe.io/t/page-number-using-macro/8164/6?u=ruchin78

Regards
Ruchin Sharma

Hi @ruchin78,

This is not working in my report.
I have created a Custom Report in my Custom app, for that I have created a report in that I have created a py file, a json file, a js file and a html file and in this html file I have designed the table and layout. So how to add the page no in that as the code above is not working there.
I think this format will work in print format for docType.
So please help me in solving this.

Regards,
Tanveer

this is my report and I have to print this and there I have to change the date format and add the page no

this is my print here I have to change the format of date and add page no

Still not able to change the date format and add page no in this custom report

Someone please help me in changing date format and adding page no in the custom report as still not found any solution for this.