PDF page numbers, headers and footers
HTML to PDF Page Numbers With Headers and Footers by API
SitePDF adds a running header, a footer and "Page 2 of 7" page numbers to every PDF it renders from your HTML. You pass the header and footer as two small HTML strings and the numbers fill in by themselves.
- PDF and archive in one call
- Plans from $49 a month
- Your HTML stays yours
Short answer
To get page numbers in an HTML to PDF render, send footer_html (and optionally header_html) with the render call and put <span class="pageNumber"></span> and <span class="totalPages"></span> inside it. SitePDF prints that block on every page in managed Chromium, so a 7 page statement reads "Page 1 of 7" through "Page 7 of 7".
Starter API is $49 a month for 10,000 renders ($288 billed yearly). Growth is $99 a month for 50,000 renders and Scale is $299 a month for 250,000.
Written and fact checked by the SitePDF team.
What a header or footer can hold
These are the placeholders Chromium fills in inside header_html and footer_html. SitePDF passes your string through unchanged, so the same rules apply as in a browser print.
| Class in your HTML | What it prints | Typical use |
|---|---|---|
pageNumber |
The number of the current page | "Page 3" in a footer |
totalPages |
The page count of the whole document | "of 12" after the page number |
date |
The date the PDF was printed | A print date in the corner of a report |
title |
The title of the HTML document | Report name in a running header |
url |
The address of the page, when you render a URL | Source line on a captured web page |
Each of header_html and footer_html is limited to 4,000 characters. Plans and prices are from our own pricing page.
A worked example with a 7 page statement
A finance team sends month end account statements. Each statement runs from 3 to 12 pages depending on the number of transactions, and the customer has to be able to say "page 5 is missing" over the phone. The render call carries the statement HTML plus a footer with the account number and the page counter.
{\n "html": "<h1>Statement 2026-11</h1>...",\n "format": "Letter",\n "margin": "normal",\n "header_html": "<div style=\"font-size:9px;width:100%;padding:0 15mm;color:#555\">Acme Ltd, account 40-1182</div>",\n "footer_html": "<div style=\"font-size:9px;width:100%;text-align:center;color:#555\">Page <span class=\"pageNumber\"></span> of <span class=\"totalPages\"></span></div>"\n}The statement above renders to 7 pages and the footer reads "Page 1 of 7" to "Page 7 of 7". The account line repeats at the top of each page, so a single loose sheet still says whose it is. At 4,000 statements a month this is 4,000 renders, which fits Starter API.
Three things that make a footer vanish
No font size. The header and footer do not inherit your page CSS. Set font-size inline on the outer element, as in the example, or the text prints too small to see.
Not enough margin. The footer is drawn inside the page margin. The normal preset gives 20 mm top and bottom, wide gives 30 mm, and none gives 0, which leaves no room for a footer. Use normal or an exact value such as 25mm.
Padding on the sides. The footer box spans the full page width, so add your own horizontal padding to line it up with the body text. Our article on margins, headers and footers in HTML to PDF covers the CSS side in more detail.
What it does not do
The same header and footer print on every page. There is no separate first page header, no different layout for odd and even pages, and no restart of numbering per section. If a contract needs a cover page without a number, render the cover and the body as two PDFs and join them in your own code.
Remote images in a header may not load in time, so embed a small logo as a base64 data URI. SitePDF does not stamp a signature or a Bates number onto the file, only the text you provide.
Where it fits next to the rest of the render call
Header and footer are two more fields on the call that already makes the PDF, so they work together with archive and the SHA-256 hash described on the invoice PDF archive page. For SaaS invoices and statements see the HTML to PDF API for SaaS.
When the statement layout is signed off in a short call with the client finance team, a meeting scheduler for client teams saves the back and forth over times. After that the layout lives in your template and nobody touches it by hand.
Who it is for and who it is not for
It is for developers whose product sends multi page documents such as statements, reports, quotes and contracts, and who want the page counter and a repeating account or document line without a PDF library.
It is not for a team that needs per section numbering, a different first page, or roman numerals for a front matter. Those need a typesetting tool such as LaTeX or a layout program, not a browser print.
curl -X POST https://api.sitepdf.com/v1/render \
-H "Authorization: Bearer $SITEPDF_KEY" \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Statement 2026-11</h1>...", "format": "Letter", "footer_html": "<div style=\"font-size:9px;width:100%;text-align:center\">Page <span class=\"pageNumber\"></span> of <span class=\"totalPages\"></span></div>"}'
This is the documented API call shape. Full request and response walkthrough.
Questions about this job
How do I add page numbers to a PDF generated from HTML?
Can I repeat a header on every page of the PDF?
Why are my page numbers not showing?
Can I leave the page number off the first page?
How much does it cost?
Index
More PDF and archiving tools
- Convert HTML to PDF
- Webpage to PDF
- URL to PDF API
- Website archiving
- Monitor website changes
- Screenshot API
- React to PDF
- Java PDF library
- C# PDF library
- Python PDF generation
- HTML to PDF Node.js
- Laravel HTML to PDF
- Vue to PDF
- Next.js PDF generator
- Angular to PDF
- Markdown to PDF API
- Django HTML to PDF
- Blazor HTML to PDF
- Spring Boot HTML to PDF
- Airtable to PDF
- Svelte to PDF
- Rotativa alternative
- Zapier and Make HTML to PDF
- Golang HTML to PDF
- Rails HTML to PDF
- PDF generator API
- Website archiving software
- Document generation API
- Legal document automation software
- Document automation software
- Bulk HTML to PDF
- Accessible PDF generation
- ADA compliance audit cost
- 508 compliance testing
- PDF remediation
- VPAT and ACR
- PDF accessibility checker
- Wayback Machine alternative
- Best HTML to PDF API
- DocRaptor alternative
- Puppeteer alternative
- Wkhtmltopdf alternative
- PDFShift pricing and alternative
- Urlbox pricing and alternative
- PDFCrowd alternative
- Api2Pdf alternative
- Browserless alternative
- APITemplate alternative
- CraftMyPDF alternative
- PDFMonkey alternative
- dompdf alternative
- WeasyPrint alternative
- jsPDF alternative
- mPDF alternative
- Website archiving pricing comparison
- HTML to PDF API for ecommerce
- HTML to PDF API for SaaS
- HTML to PDF API for accounting software
- PHP convert HTML to PDF
- PrinceXML alternative
- PDFreactor alternative
- PDF integrity check
- Invoice PDF archive
- PDF of pages behind a login
- Website archiving for law firms
- React PDF renderer alternative
- Gotenberg alternative
- GrabzIt alternative
- Adobe PDF Services API
- PDF SDK pricing
- HTML to image API pricing
- Adobe Document Generation API pricing
- jsreport pricing
- PDFBolt pricing
- PDFEndpoint pricing
- Formstack Documents pricing
- Documint pricing
- iLovePDF API pricing
- Browserless pricing
- PandaDoc API pricing
- CloudConvert API pricing
- Encodian pricing
- IronPDF pricing
- Salesforce document generation pricing
- Winnovative pricing
- SelectPdf, HiQPdf and EvoPdf pricing
- CloudConvert alternative
- Direct mail API pricing
- E-signature API pricing
- Sparticuz Chromium Lambda cost
- Browserbase pricing
- Aspose PDF pricing
- PDF API pricing
- How it works
- Features
- Pricing
Get started
Render and archive with one API call
A pixel perfect PDF and a dated copy of the page from the same request. Plans from $49 a month, half price billed yearly.