I need print page number when printing html in Chrome Version 52.0.2743.116 m (64-bit). However I haven't found the answer yet.
I have already tried this:
@page {
@bottom-right {
content: counter(page) " of " counter(pages);
}
}
This didn't work at all.
Then I have found this Q&A:
For this answer we are not using @page, which is a pure CSS answer, but work in FireFox 20+ versions. Here is the link of an example. 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>
Unfortunately, this works only in FireFox 20+ versions and Chrome Version 35.0.1916.153
Downgrade isn't an answer. Can you help me, please?
On any website in Chrome, hit Ctrl+P on your keyboard to bring up the print dialog box.
If you are looking to add page numbers when printing under Chrome/Chromium, one easy solution is to use Paged. js. This JS library takes your HTML/CSS and cuts it into pages, ready to print as a book, that you will preview in your browser. It makes the @page and most the CSS3 specifications work for Chrome.
If you want page numbers to print in the header or footer of the form when users print it, use AutoText codes in the Insert Header and Insert Footer dialog boxes. On the View menu, click Header and Footer. Click the Print Settings tab. Under Headers and Footers, click Header or Footer.
This set up works for me, you just need an element at the end of each page to append a page counter onto.
Code:
HTML:
body {
counter-reset: section;
}
@media print {
.page {
page-break-after: always;
}
.page .pageEnd::after {
counter-increment: section;
/* Increment the section counter*/
content: "Page " counter(section) " ";
/* Display the counter */
}
}
<div class="page">
<h2>Here is page 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quas nulla accusantium, veritatis quidem voluptas ex, atque suscipit incidunt, dolore sunt reiciendis cum obcaecati, iste necessitatibus doloribus cumque facere beatae. Ratione?</p>
<div class="pageEnd"></div>
</div>
<div class="page">
<h2>Here is page 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quas nulla accusantium, veritatis quidem voluptas ex, atque suscipit incidunt, dolore sunt reiciendis cum obcaecati, iste necessitatibus doloribus cumque facere beatae. Ratione?</p>
<div class="pageEnd"></div>
</div>
<div class="page">
<h2>Here is page 3</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quas nulla accusantium, veritatis quidem voluptas ex, atque suscipit incidunt, dolore sunt reiciendis cum obcaecati, iste necessitatibus doloribus cumque facere beatae. Ratione?</p>
<div class="pageEnd"></div>
</div>
<div class="page">
<h2>Here is page 4</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quas nulla accusantium, veritatis quidem voluptas ex, atque suscipit incidunt, dolore sunt reiciendis cum obcaecati, iste necessitatibus doloribus cumque facere beatae. Ratione?</p>
<div class="pageEnd"></div>
</div>
<div class="page">
<h2>Here is page 5</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quas nulla accusantium, veritatis quidem voluptas ex, atque suscipit incidunt, dolore sunt reiciendis cum obcaecati, iste necessitatibus doloribus cumque facere beatae. Ratione?</p>
<div class="pageEnd"></div>
</div>
<div class="page">
<h2>Here is page 6</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quas nulla accusantium, veritatis quidem voluptas ex, atque suscipit incidunt, dolore sunt reiciendis cum obcaecati, iste necessitatibus doloribus cumque facere beatae. Ratione?</p>
<div class="pageEnd"></div>
</div>
<div class="page">
<h2>Here is page 7</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quas nulla accusantium, veritatis quidem voluptas ex, atque suscipit incidunt, dolore sunt reiciendis cum obcaecati, iste necessitatibus doloribus cumque facere beatae. Ratione?</p>
<div class="pageEnd"></div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With