CSS page counters - total pages occupied for a section

Amit Phaltankar

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?

Amit Phaltankar

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.

edited at
0

Comments

0 comments
Login to comment

Related

print page count with total number of pages using css

Pagination Current page/Total pages?

how to show text like 2 / 4 "page number / total pages" in css or css3

Get Total Pages Count and Current Page QuickLook

Wrong number of total pages in returned Page

PHP: how to print $page / $total_pages in each page without knowing $total_pages?

Trying to place a custom field after the total section in the checkout page in woocommerce

MigraDoc: How to add a blank page after a section on odd pages?

HTML/CSS how to temporarily highlight a section of a page

Properly add page numbers and total number of pages to PDF using ReportLab

Get total pages of pagination Laravel and write to file page number

Using CSS Counters

Flexbox order + CSS counters

CSS: How to have multiple counters in nested counters

PHP page hit counters in database

Multiple javascript counters on the same page

jQuery detect when total value of counters are 0

How to find the total space occupied by a cassandra keyspace?

Find the total space occupied by the ISO's on FS?

How to get page occupied by graphs

CSS counters for headings nested in div

How to nest multiple counters in css?

Legal style list counters in CSS

Apply different css style file on different section tags on single page

How to delete the css styles in my wordpress home page head section

Trigger a CSS Animation when the user scrolls to page section

Keeping the section 1 active on page refresh(Javascript + css)

How to change the background of a page section in Squarespace using CSS?

How to show the total number of pages in a PDF via the RMarkdown (i.e. display "Page 1 of 10")?