Add Page Numbers to a PDF (and Headers and Footers)
Learning to add page numbers to a PDF is the rare office skill where the obvious way and the correct way are different things. The obvious way is to tick "print page numbers" in the print dialog. The correct way is to put the numbers into the file itself. This article covers why, the tokens that do the work, where to place them so they don't collide with your content, what rotated pages do to naive stamping, and the one ordering rule that keeps your numbers honest.
Why the number belongs in the file, not the printer
Print-dialog page numbering is done by whatever program happens to print the file. That has three consequences, none of them good.
First, the numbers exist only on paper. Open the same PDF on screen, send it to a colleague, or extract a page, and the numbering is gone. A contract referenced as "see page 14" is useless if the number 14 was a print-time illusion.
Second, every recipient gets different settings. One reader prints with headers, another without; one scales to fit, another prints at 100 percent. If a page number's position depends on the viewer's print margins, you don't control where it lands.
Third, print numbering counts sheets, not pages. Print pages 5 through 9 of a document and most drivers will stamp them "1" through "5", which is a great way to produce a handout whose numbers contradict its own table of contents.
A number drawn into the page content travels with the page. It survives copying, printing, extracting, and twenty years of software changes, which is the whole point of PDF. ISO 32000 defines pages as self-contained descriptions of their own appearance, and a footer is part of that appearance.
The tokens
In LivePDF, the Header and footer dialog gives you six text slots: top left, top center, top right, bottom left, bottom center, bottom right. The dialog itself explains the convention: "Write into any of the six places. {page}, {pages}, {date}, {title}, {file}, and {bates} are filled in for each page."
Those six tokens cover most jobs:
{page}becomes the current page number,{pages}the total count.Page {page} of {pages}is the standard footer.{title}and{file}pull the document's title metadata and its filename, useful for the many office documents that circulate detached from their original name.{date}inserts the stamping date in the reader's locale.{bates}becomes a Bates number: an optional prefix and suffix around a zero-padded counter with a configurable start value and digit width. The default layout is six digits, producing labels likeABC000001. Bates numbering exists because legal productions need every page of a large document set to carry a unique identifier, and it is offered in LivePDF both in the header/footer dialog and in the batch tools.
The plain "Add page numbers" command is a shortcut for the common case: it offers a position (bottom center by default), a size, a format such as "Page 1 of 12", and a start value.
Placement: margins and not stamping over content
A page number that overlaps the body text is worse than no page number. Three practical rules.
Stay inside the printable zone. Most home and office printers can't print to the absolute edge of the sheet; anything closer than roughly a centimeter risks being clipped. LivePDF insets header and footer text 28 points (about 9.9 mm) from the page edge by default, which sits inside that safety zone, and the size control runs from 6 to 36 points so you can shrink rather than crowd.
Use a slot your content doesn't use. Documents built in Word or LaTeX usually leave the bottom margin empty, which is why bottom center is the convention. Scans and slide exports are less predictable; if a scan already has a footer baked into the image, put your number top right instead. You get six slots precisely so you can route around existing content.
Watch the width check. A long footer string at a large size can overflow the page. LivePDF measures the text's actual rendered width and refuses the operation with an error naming the page, rather than producing a number that runs off the paper. If you hit that error, shorten the text or drop the font size.
Rotated pages need swapped coordinates
Here is the part that breaks naive stamping scripts. Every PDF page carries a /Rotate value (0, 90, 180, or 270), and per ISO 32000 that rotation is applied at display time. A page from a scanner can easily be stored sideways with /Rotate 90 telling the viewer to turn it upright.
Coordinates in the content stream, however, ignore rotation. A stamper that computes "bottom center" in raw page coordinates and draws there will stamp the wrong edge of a rotated page: on a /Rotate 90 page, the visual bottom is the coordinate left side, and on /Rotate 180 it is the top. The stamp comes out sideways or in the wrong corner, a bug class well documented in stamping tools, and the fix is always the same: read the page's rotation first, and map the corner the reader sees onto the underlying coordinate system, swapping width and height for the quarter-turn cases. LivePDF does this mapping for every stamped page, so a document of mixed portrait and landscape pages gets numbers that all read upright at the bottom of the visible page.
Starting numbers and cover pages
Cover pages break naive numbering. A report with a cover has "page 1" as the cover and "page 2" on the first page of content, which is not what any reader expects.
There are two tools for this. The Add page numbers dialog has a Start at field: set it to 2 and the cover counts without showing a number (leave it out of the page selection), while the first content page prints "2". For heavier cases, the Bates start number serves the same role with a prefix, so a set of exhibits can begin anywhere: EXH-C-0041.
One honest caveat: the {page} token in the full header/footer dialog always counts physical pages, starting at 1 for the first page of the file. If you need an offset, use the Add page numbers command's Start at field or a Bates start; {page} itself has no offset parameter.
The one edit you must do last
Every stamped number is baked into the page as literal text. That gives page numbering a property no other edit has: it goes stale the moment you rearrange the document.
Delete page 3 after stamping and the file jumps from "Page 2" to "Page 4" with nothing in between, and every later page now lies about its position. Move pages around in the organize grid and the numbers travel with the pages, not with their positions, so the document reads 4, 9, 2. Stamp {pages} into a 20-page file and then append a 5-page appendix; the footers still say "of 20" forever, because the token was resolved to a literal string at stamping time.
Every structural edit — merging files, splitting, deleting, reordering, rotating — changes what the correct number would be, which means the number is correct only if nothing structural happens after it. Page numbers are the one edit that must come after the document has reached its final arrangement. Finish the arrangement first, then stamp.
The corollary: if you do change the structure later, don't patch numbers by hand. Remove the old headers and footers and stamp again. It's one dialog instead of thirty corrections, and a document that went through combine-and-OCR pipelines or a late merge should be renumbered as a whole, the same way you'd re-run a batch job over changed files rather than editing each output.
Sources and further reading
- ISO 32000-1:2008 (PDF 1.7), free download from Adobe — page dictionaries and the
/Rotateentry (§7.7.3.3, Table 30) - pdfcpu stamp documentation — position anchors and the
%p/%Ptoken convention in a CLI stamper - Aspose PDF PageNumberStamp reference — the
#token convention, showing how each tool spells the same format string differently
FAQ
How do I add page numbers to a PDF without installing anything?
Open the file in LivePDF, choose Insert > Page numbers (or Header and footer for custom text), pick a position and size, and save. Everything runs in the browser, so the file never leaves your machine.
Why is my page number off by one because of the cover page?
The {page} token counts physical pages, so a cover makes every printed number one lower than expected. Use the Start at offset in the page numbers dialog, or a Bates start number, to compensate.
What is a Bates number and when do I need one?
A Bates number is a prefixed, zero-padded page label (ABC000001, ABC000002...) used in legal productions so every page of a document set has a unique ID. It is the same stamping operation as a page number with a different format string.