i guess this is the same question that the one here, so let's move the conversation here.
That works but I don't want to put it in to the header for wkhtmltopdf. I'm trying to design a template that would look identical (or close) in HTML and PDF rendering.
previous reply from the linked topic:
hmm then i think you can try the same logic that the watermark, just that in your case you can change it to show page number at the right-top and instead of a watermark just render the current page wich is available from JS