I am using CSS @page and page counters for a report I am generating.
I am able to make use of
counter(page); /* shows current page */
counter(pages); /* shows total pages */
I show the page information on the footer
For the nested sections in my document I am creating my own sectional counter and able to track my sectional page count.
counter(mySectionCounter)
Now, is there any way that I can show total number of pages occupied my particular section?
All I want to do it show section specific header on each page.
My First Nested Section (page 1 of 2)
.
. First Section
.
My First Nested Section (page 2 of 2)
.
. First Section
.
My Second Nested Section (page 1 of 4)
.
. Second Section
.
.
How to find the sectional total page count?
After trying almost everything in flying-saucer the conclusion was, we need to have JavaScript support for showing the Sectional Page Counter and Sectional Page Count on the PDF.
If the Sectional Total Page count is kind of an MVP, I suggest to go for a different tool which support JavaScript rendering.
html2pdf
I found html2pdf
tool (free to use) which can do almost everything that flying-saucer supports with and addition of support for JavaScript. It is a command line tool needs to be installed and then can be called from Java Code.
with JS it is easy to link page-pages to a JS function with keeps track of total pages in current section.
More information on html2pdf can be found here:https://html2pdf.com/
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments