Requirement:
To have a overall paging on the document i.e. Page 1 of 20
To have section wise paging as well i.e. Page 1 of 5.
Problem:
We are unable to display section wise page.
Approach:
Overall paging
For overall paging, we have used
TextFragment hfHeaderTxt2 = new TextFragment(“Page $p of $P”);
The above code is being called in “page.OnBeforePageGenerate” event. (see line#258 in pdfHelper.cs)
Section wise Paging
Our document contains multiple section. Each section may render on multiple pages. For example: we have 2 sections i.e. “section ABC” and “section XYZ”.
Content of “section ABC” renders in 3 pages. so each page header should show
“Page 1 of 3”, “Page 2 of 3” and so on.
Paging should be reset when a new section starts.
We are managed to print the page number and able to reset when new section starts (see implementation in AddHeader method at line#229). We are unable to get the total count of pages a section will take, hence not able to show total count of page.
Please see the attached [PdfGenerationApplication.zip]
Addmethod at line#158 is the method responsible for creating pdf docuement. This method calls OnPageGenerate event responsible for displaying header and paging.