It paginates wrong
Page numbers are missing or all show 1
Either the page number area is empty, or every page says the same number, usually 1 of 1.
What is actually happening
Page numbers come from the footer template's special classes, not from CSS counters in the document body. A CSS counter(page) in the body has no page context to count. The all-ones case usually means the number is in the body rather than the footer.
Confirming it is this and not something that looks like it
Look at where the number lives. If it is in your document markup rather than in the footer template, that is the whole explanation.
The fix
Put the page number in the footer template using the pageNumber and totalPages classes, which the renderer substitutes per page. Leave the document body out of it.
<!-- footerTemplate, not document body. The classes are substituted per page. -->
<div style="font-size:9pt;font-family:sans-serif;width:100%;padding:0 16mm;
display:flex;justify-content:space-between;color:#555">
<span>Statement for March 2026</span>
<span>
Page <span class="pageNumber"></span> of <span class="totalPages"></span>
</span>
</div>If that was not it
These produce the same symptom often enough to be worth ruling out before assuming the fix above did not work.
- displayHeaderFooter left off, which makes the templates inert
- The classes misspelled, which fails silently rather than erroring
- A bottom margin too small to show the footer at all
- Wanting the number to start at something other than 1, which the footer template cannot do arithmetic for
Frequently asked
Does this happen with every rendering engine?
The behaviour behind it is not specific to one tool. Page numbers come from the footer template's special classes, not from CSS counters in the document body. Anything rendering HTML to a paged medium has to make the same decision, so the fix travels with you if you change how the render happens.
Will this show up as an error in my logs?
No, and that is what makes it expensive. A document that renders wrong is still a successful render as far as every log line is concerned. It is found by someone opening the file, which is usually the customer.
Related failures
Problems people arrive at from the same starting point, or mistake for this one.
Page breaks land in the wrong place
Nothing told the layout where it is allowed to break, so it breaks wherever the content runs out of page.
Table headers do not repeat on the next page
Header repetition is driven by table sectioning, not by styling.
There is an extra blank page at the end
Something extends a fraction of a millimetre past the end of the last page.
Content is cut off at the right edge of the page
The element is wider than the page's content box and has nothing telling it to wrap.
Page margins are ignored in a generated PDF
Same collision as page size: a margin set in the render options and a margin set in an @page rule, with the engine picking one.
CSS for paged documents, and what actually works
Which parts of the paged media specification a browser-based render implements.
Everything that goes wrong, by category
The full list, grouped by where in the pipeline it breaks.
Paste your markup and see the rendered document, without signing up.