{"id":1531,"date":"2010-08-20T12:41:22","date_gmt":"2010-08-20T07:11:22","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=1531"},"modified":"2016-12-15T18:17:01","modified_gmt":"2016-12-15T12:47:01","slug":"add-page-number-using-page-property-of-css","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/add-page-number-using-page-property-of-css\/","title":{"rendered":"Add Page number using Page Property of CSS"},"content":{"rendered":"<p>In my recent <a title=\"Nodejs development\" href=\"http:\/\/www.tothenew.com\/mean-node-js-development-consulting\">Nodejs project<\/a>, we were required to generate the pdf document from HTML page. We are using iText renderer for doing this. The client had the requirement that each page bottom right needed to have a\u00a0number on it. All these things need to be replicated on every page.<\/p>\n<p>So for doing this we need to know more about the CSS3 page properties. I found the solution in this documentation http:\/\/www.w3.org\/TR\/css3-page\/ and http:\/\/www.w3.org\/TR\/CSS21\/generate.html#counters<\/p>\n<p>For doing this I did something like<\/p>\n<pre>@page {\r\n        margin-top: 149px;\r\n        margin-left: 2px;\r\n        margin-bottom: 40px;\r\n        margin-right: 2px;\r\n        size: landscape;\r\n        counter-increment: page;\r\n\r\n     @bottom-right {\r\npadding-right:20px;\r\n        content: \"Page \" counter(page);\r\n      }\r\n\r\n    }\r\n<\/pre>\n<p>We added an incremental page counter in the page property which can be reset as well. As my counter was incrementing after each page so I defined counter-interment at page level, although depending on the cases you can increment the counter before or after an\u00a0occurrence of any element like.<\/p>\n<pre>.incrementClass:before {\r\n   counter-increment: page;\r\n}  \r\n<\/pre>\n<p>in above example, counter will be incremented before the incrementClass appears on the page.<br \/>\nHope it helps<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my recent Nodejs project, we were required to generate the pdf document from HTML page. We are using iText renderer for doing this. The client had the requirement that each page bottom right needed to have a\u00a0number on it. All these things need to be replicated on every page. So for doing this we [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":164},"categories":[1185],"tags":[372,373,355,356],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1531"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=1531"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1531\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=1531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=1531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=1531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}