How to capture current page number in print format

My print format contains index page & i need to enter page number dynamically.
So just need to know how can i get current page number in print format

What have you tried so far?

Check out this code: frappe/standard.html at develop · frappe/frappe · GitHub

<p class="text-center small page-number visible-pdf"> {{ _("Page {0} of {1}").format('<span class="page"></span>', '<span class="topage"></span>') }} </p>

Have already tried above code but now working.
I pasted the code on one of the pages but it give output as “Page of”

@Sagar_Vora any other solution available??

This works only on PDF. We are not using the default print option for now.

1 Like

Ya i know, i am also using pdf only. I want to get current page number for building index page.

@rmehta … can u please give any suggestion/solution for my query if possible.

This might help.

You can create divs and assign page number of each section to them using above script.

@Sagar_Vora exactly where should i place this code…??

Hi, how do you create you print format? I’ve created
Standard Yes
Custom Print Format True
Print Format Type Server
and then I’ve added my HTML to HTML field with this part
<p class="text-center small page-number visible-pdf"> {{ _("Page {0} of {1}").format('<span class="page"></span>', '<span class="topage"></span>') }} </p>

@SwitsolAG even i have done the same but here the problem is i need to create index page in my print format. In index page i need to print page numbers. How can i get the page numbers beforehand as they are generated after converted to pdf .

how do you generate your page number? have you tried to add this(which I wrote below) code into the your generation process?

Yes i have added the above code to generate page number but how can i fetch it to display on index page

sorry, but I cannot understand what you want

@SwitsolAG, Page number is generated at run time, so how can i fetch that page number & display on my index page. this is my query,if you are not understanding then its ok…

I think you should check function subst() in the frappe\frappe\templates\pdf_header_footer.html maybe it can help

@Varna Hello, Have u been successful in creating table of content for you prints and pdf. I also have similar usecase.