Guide
Numbering PDF pages the way printed documents do
By Logappradeep · ServiceNow developer
Page numbers make a long document usable. Reviewers can say "see page 14", printed copies can be put back in order after they are dropped, and court filings, theses and tender documents often require them. When a PDF was assembled from several sources, numbers are frequently missing or inconsistent, and adding them afterward is the practical fix.
Options you can set
- Position: top or bottom, aligned left, center or right. Bottom center is the most common choice for reports; bottom right suits documents that will be bound on the left.
- Format: a plain number (
7), a label (Page 7), or a total (Page 7 of 32or7 / 32). Showing the total helps readers notice missing pages. - Start number: begin at any value, useful when the PDF is one chapter of a larger work and should continue from the previous part.
- Skip first page: the cover gets no number and numbering begins on the second page with your start number. Set the start to 2 if the cover should count as page 1.
- Pages to number: limit numbering to a range, such as leaving out appendices at the end.
- Font size and margin: both set in points; keep the numbers small and far enough from the edge that a printer will not clip them.
How numbers are placed
For each page, the tool measures the page's size, works out the coordinates for the chosen position and margin, and draws the number as text using a standard font. Because the number is added as a new layer of drawing instructions, the existing content is untouched, text remains selectable and the file barely grows. Pages with different sizes, such as a landscape table in a portrait report, each get correctly positioned numbers. Everything is calculated locally with pdf-lib, so the document is never uploaded.
Avoiding common problems
Check whether the document already has numbers in its footer. Adding a second set in the same spot creates overlapping digits; pick another position or remove the old numbers at the source. Use the preview to step through numbered pages before saving. Pages that carry a rotation setting are handled so that "bottom" means the bottom as you see the page on screen, not as it is stored internally.
Margins below about half an inch (36 points) can fall in the unprintable area of office printers. If the PDF will be bound, leave extra room on the binding side.
Page numbers versus page labels
PDF readers show their own page index in the toolbar, counted from 1 at the physical start of the file. The numbers this tool adds are visible on the page itself. If you skip the cover or start at a different number, the printed number and the reader's index will differ, which is normal and matches how printed books work.
Add numbers as one of the last steps, after merging, reordering and removing pages, so the sequence matches the final document.