The browser that I have to support is Chrome (using electron for my project), so using any other browser is not an option.
I've looked for the solution to this problem for a while, it doesn't seem to have an answer to it. I've tried using this form of approach (copied from CSS page x of y for @media print):
The CSS is:
#content {
display: table;
}
#pageFooter {
display: table-footer-group;
}
#pageFooter:after {
counter-increment: page;
content: counter(page);
}
And the HTML code is:
<div id="content">
<div id="pageFooter">Page </div>
multi-page content here...
</div>
The approach above works on FF but not on Chrome. It seems like thead/tfoot
of chrome repeats on every printed page on print preview, but it doesn't results in any counter increment. The same counter value is printed on every printed page.
I also tried approaches that involve @page
, but this seems to stop working a couple of years ago.
Example (copied from Browser Support for CSS Page Numbers):
@page {
counter-increment: page;
counter-reset: page 1;
@top-right {
content: "Page " counter(page) " of " counter(pages);
}
}
Does anyone know a workaround for this problem? Or Am I dead in the water? Any javasript/nodejs solution is welcome.