Running heads and page numbers, placed where the page really is
Initializing in your browser…
A report of mixed paper sizes needs a dated header and page numbers, and some of its pages are cropped.
Input
report.pdf · header "{isodate}" · footer "Page {page} of {total}" · 36pt marginOutput
2026-09-06 at the top and "Page 3 of 12" at the bottom of every page, each exactly 36 points from the edge the reader sees
Every token is substituted in the FILE and not only in the preview, from one table both of them read. The margin is measured from the edge of what the page SHOWS, which is the CropBox clipped to the MediaBox, so a cropped page keeps its header where it can be seen rather than 40 points above the visible area, and it is the same distance on Letter, A4 and A5 alike. The edge is mapped through the page's own /Rotate, so a sideways scan gets its header across the top the reader sees.
Add running heads, footers and page numbers to a PDF. Type the text or take a preset, choose left, centre or right for each, and set the size, the font, the colour and how far in from the edge they sit. Eight tokens are substituted per page, in the file and not just on screen: {page}, {total}, {pageof}, {date}, {isodate}, {time}, {year} and {filename}. The preview is a render of the actual page with the resolved lines drawn on it, at the positions the file will hold. The lines are measured from the edge of what the page SHOWS rather than from the paper, and mapped through the page's own rotation, so a cropped page, an offset box and a sideways scan all get their header where a reader will find it.
Add "Page 3 of 12" footers to a long document. Do it after merging, so the numbers match the joined file.
Put the document title or the file name in the header of every page, which is what many submission guidelines ask for.
Stamp the date and time a draft was produced, so two printouts of the same document can be told apart.
Add a required reference number or disclaimer to every page of a contract or filing.
A file of Letter, A4, Letter landscape and A5 pages gets its footer exactly 34 points from the bottom of every one, because the margin is a length measured from the visible edge rather than a fraction of the page.
On a page cropped to [72, 72, 540, 720] the header lands at y 675 to 684, inside what the reader sees. Measured from the paper instead it would sit at 760, which the viewer never shows.
The "Date and pages" preset writes 2026-09-06 into the file. The shipped version wrote the eight characters "{isodate}" onto every page and showed the real date only in the preview.
A header is a mark anchored to the top edge and a footer one anchored to the bottom, so this tool and the watermark adder share their placement arithmetic. Three things decide whether either lands where you asked.
The first is that the edge of the page is the edge of what the page SHOWS. A page can carry a CropBox, in which case a viewer shows only the intersection of that box with the MediaBox (ISO 32000-1 clause 14.11.2), and a MediaBox does not have to start at the origin. Measuring from the paper instead puts a header where nobody can see it: on a Letter page cropped to [72, 72, 540, 720], a header written 30 points below the top of the MediaBox lands 40 points ABOVE anything the reader is looking at, and the matching footer lands 54 points below it.
The second is the /Rotate entry, which turns a page clockwise when it is displayed. pdf-lib draws in raw page space and applies none of it, so a line written at "the top" of a page carrying /Rotate 90 comes out down the side, sideways. Here the edge is mapped back through the page's own rotation and the text is turned with it, which matters for any scan whose pages are not all the same way up.
The third is the distance from the edge, which has to be a real length rather than a constant. A fixed inset is a different proportion of every paper size, so a document mixing Letter, A4 and A5 gets visually inconsistent margins. The margin here is set in points and measured from the edge of the visible area, so it is the same distance on every page whatever the paper.
Eight tokens are substituted, and they are substituted in the FILE and not only in the preview: {page}, {total}, {pageof}, {date}, {isodate}, {time}, {year} and {filename}. One table is read by both the preview and the writer, so the two cannot drift apart. A token the tool does not know is named before you press anything, rather than being printed onto every page of the document.
One limitation is stated rather than hidden. The standard PDF fonts are single byte and can only draw what WinAnsiEncoding names, so Cyrillic, Greek and CJK text cannot be drawn; the tool checks your text against the same table the embedder uses and says which characters are the problem.
Yes. Leave either field empty and only the one you fill in is added. With both empty nothing runs.
It can. The lines are drawn on top of the page and nothing is moved out of the way, so a document whose text already reaches the edge may need a larger margin. The preview shows exactly where the text will land, on a render of your own page.
{page}, {total}, {pageof}, {date}, {isodate}, {time}, {year} and {filename}, and all of them are substituted in the downloaded file as well as in the preview. A token the tool does not recognise is named on the page before you press anything.
Yes. Six standard PDF fonts and any hex colour are written into the document itself.
It says the page's number in the whole document. Numbering pages 4 to 6 of a six page file gives 4, 5 and 6, not 1, 2 and 3.
Both are handled. The margin is measured from the edge of the area the page actually shows, and the edge you pick is mapped through the page's own /Rotate, so a sideways scan gets its header across the top as the reader sees it, the right way up.
The fourteen standard PDF fonts are single byte and can only draw what WinAnsiEncoding names, which is Latin script plus a set of symbols. The tool checks your text against that table and names the characters it cannot draw.
PDF parsing and editing happen in your browser. Documents, and everything inside them, are never uploaded or stored remotely.