+ Start a Discussion
Nazeer AhamedNazeer Ahamed 

Page Number in PDF generated using Visual force

Can we count page Number based on <apex:repeat> tag.

Say example visual force generates PDF from list button where 2 records are selected and result page is totally 5.
With help apex repeat tag, for the first record 3 pages and second record it is next 2 pages generated in a single file.
I want count a page number in a PDF doc as Page 1 of 3, 2 0f 3, 3 0f 3 and then again 1 of 2 and 2 of 2.

Is it possible? I am using below code to display page number it is counting from 1 to 5.

<HEAD> <style type="text/css"> @page { @bottom-center{ content: "Page " counter(page) " of " counter(pages); } } } </style> </HEAD>

 

Ispita_NavatarIspita_Navatar

The question is how you will be able to find out the pages a particular record will span?

Say in this case Rec#1 spans 3 pages and Rec#2 spans 2 pages.


If yes then you can use a loop to store the id for the record and check it as you are printing the page number whenever the record id you can restart the counter.


1. say you loop through the records selected

2. As you loop through the records in a variable RecIdTemp= Recid# i th here i=1

3. Check in every page if RecIdTemp == Rec#[i] {where i is the counter}

         yes- increment pages

         no - reassign RecIdTemp=Recid#2 i th here i=2

Reset Page to 1 and pages to 1

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

vikramraj muthayalavikramraj muthayala
Hi Nazzy,

I also have a similar requirement,
If you had figured out the Solution ... Could you let me know ?