Get number of pages out of header and footer
-
Hi everyone, again! :)
I'm using a razor view to render PDF, I've enabled header and footer and everything works right but....I need to show a div only if there's more than one page.
In my footer I have the classic 1 of 2 pages but I'm not able to get that value in the main view.
Is it only possible in headers and footers?
Thanks in advance
-
Can you determine that you will render more pages based on your data?
In that case, you can use the templating engine to hide the header.{{#if shouldDisplayHeader}} <div .../> {{/if}}
If you can't, then look at the jsreport pdf utils. It lets you create fully dynamic headers.
https://jsreport.net/learn/pdf-utils
https://github.com/jsreport/jsreport-dotnet-example-webapp/blob/master/Controllers/HomeController.cs#L93
-
No, I can't determine if the final pdf rendered is going to have one o two pages.
I've check every sample and threads in StackOverflow but I'm not able to figure out how to get the number of the page in the view that render the content (and not being header or footer)
Don't not if I'm explaining myself right, my fault.
-
The answer in the post
https://forum.jsreport.net/topic/1940/how-to-get-current-page-number-in-content-html-page
helped me