PDF Header & Footer

Stamp running headers and footers onto a PDF, with page numbers, dates and page ranges.

About adding headers and footers to a PDF

A PDF has no concept of a running header. Word processors and typesetters generate one while laying the document out, and by the time it becomes a PDF the result is just ink on each page. So adding a header after the fact means drawing text onto every page — which is exactly what this tool does, with six independently addressable slots and placeholders that resolve differently on each page.

The six slots

Left, centre and right, in a header band and a footer band. Each band can be switched off entirely, and each slot is optional — leaving one blank simply draws nothing there. The convention most documents follow is a title or document reference in the header and administrative detail in the footer: a revision number bottom left, a confidentiality notice bottom centre, page numbers bottom right. Every slot is a single line of text anchored at one point; there is no wrapping and no collision detection, so a long string will run into its neighbour. The preview shows the real geometry against your actual page, which is the quickest way to catch that.

Placeholders

  • {page} — the page's physical position in the document, counting from one.
  • {total} — the document's total page count, unaffected by the range you stamp.
  • {date} — today's date, in one of five fixed formats chosen in the settings. It is written out by hand rather than through the browser's locale machinery, so the string is identical on every machine.
  • {filename} — the uploaded file's name with the .pdf extension removed.

They can be mixed with ordinary text and repeated, so {filename} — {page}/{total} — {date} works as written. The little buttons beside each field append a token at the end; you can also just type the braces.

Why the CropBox, and not the page size

Every position here is measured from the page's CropBox — the rectangle a reader displays — rather than the MediaBox, which is the sheet the page was composed on. On an ordinary office document they are the same and the distinction is academic. On anything prepared for print they are not: the MediaBox is typically 3 to 6 mm larger on each side to carry bleed and registration marks. Measuring a footer from the MediaBox on such a file puts it below the visible page, where it looks broken on screen and is trimmed away on press. The same reasoning applies to a file that has been through a crop: its CropBox is smaller than its sheet, and the header belongs inside the crop.

Two details of the format make that rectangle less obvious than it sounds. A PDF rectangle is four numbers naming two opposite corners, and the order is not guaranteed — plenty of files store them back to front — so the box is normalised before anything is measured from it. And a CropBox only means anything where it overlaps the MediaBox, so the two are intersected; a CropBox larger than the sheet is clipped back to the sheet rather than taken at face value. Both steps match what a reader does, which is also how the preview on this page is computed, so what you see and what you download agree even on a malformed file. Each page's /Rotate value is undone before the coordinates are written, so landscape and sideways-scanned pages are stamped in the orientation you see rather than the one stored on disk; a rotation that is not a multiple of 90 is invalid and readers ignore it, so it is treated as zero here too.

Fonts, size and colour

Three faces are offered — Helvetica, Times Roman and Courier — each with a bold variant. All six are members of the fourteen standard fonts that every conforming PDF reader is required to provide, which means no font program has to be embedded, so the hundred-odd kilobytes one would cost is never spent and the text renders identically everywhere. What the file does gain is the ink: every stamped page picks up a small content stream carrying one text-drawing instruction per filled slot. That is about two hundred bytes for a page with a single footer and roughly four hundred for a page with all six, so a 60-page report with a page number grows by about 12 KB and a 300-page document with all six slots filled by a little over 100 KB. It scales with pages times slots, not with the size of the document, and nothing existing is re-encoded.

The trade-off for skipping embedding is coverage. These fonts encode WinAnsi, roughly Latin-1 plus common typographic characters, so Western European accents are fine — é, ü, ñ, ç, å — but nothing beyond that is. Emoji, Greek, Cyrillic, Arabic, Hebrew and CJK are out, and so are the Central and Eastern European Latin letters that Latin-1 never covered: Polish ł and ą, Czech ř, Hungarian ő, Romanian ș. Invisible characters count too — a tab pasted in from a spreadsheet cannot be drawn either. The text is checked before any ink is placed, and if something cannot be drawn the run stops with nothing written and the message names each offending character with its code point, describing the invisible ones by name. That check covers what the placeholders expand to as well, so a file whose own name contains one of these letters will be refused while {filename} is in a slot. A line break never reaches the check: a slot is one line, and pasting text that spans several turns each break into a space, with a note saying it happened — the browser's own behaviour for a single-line field is to delete the breaks and run the lines together, which is worse and silent. Size is in points and is limited to 4 to 48; anything outside that, or left empty, is replaced by the nearest allowed value, and the number actually in use is shown and drawn in the preview so the setting and the file never disagree. The margin is in millimetres, 0 to 60, and is measured from the page edge to the ink rather than to the baseline: the header's ascenders stop at the margin and the footer's descenders stop at it, so equal margins leave equal white space top and bottom. The colour picker writes an exact RGB value.

Scope, and what cannot be undone

Stamp the whole document, or type a range like 2-9, 12; the separate skip-the-first-page checkbox handles the common case of a cover sheet. Pages left out are untouched, and the preview says so: turn to one of them and it is drawn bare, with a line underneath naming the reason, so the setting can be checked without downloading anything. A page number past the end of the document is reported rather than quietly ignored, and that applies to both ends of a range — on a three-page file, 1-999 is refused exactly as 4 is, because it usually means the wrong file is loaded. Text that is not a page number at all is reported as its own kind of mistake, since being told that a twelve-page PDF cannot use “abc” explains nothing. Settings, the range included, stay put when you swap files, so check the range still suits the new document. What you cannot do is remove the result later: the text joins each page's content stream and is then indistinguishable from the rest of the page, so keep the original if there is any chance you will want to change the wording. Run the tool twice and you get two overlapping headers, not a replacement. For text that needs to sit somewhere other than the six slots, PDF Editor places a box anywhere on a page; for a diagonal DRAFT across the middle, Watermark PDF is the right tool; and for plain sequential numbering with no other text, Page Numbers PDF does it in one click. Everything runs in this browser tab — nothing about the document is transmitted anywhere.

Six independent slots

Left, centre and right in the header, and the same three in the footer. Fill in only the ones you need — a document number top left, a confidential notice bottom centre and a page count bottom right is three fields and one pass.

Placeholders that resolve per page

Type {page}, {total}, {date} or {filename} anywhere in a slot. Page and total are the physical numbers in the document, the date is the day you run the tool in the format you pick, and filename is the source file without its .pdf extension.

Measured from the CropBox

Positions are taken from the rectangle a reader actually displays, not from the MediaBox. On a print-ready file with bleed those differ by several millimetres, which is exactly how footers end up hanging off the visible page. The CropBox is put the right way round and clipped to the sheet first, so a malformed one cannot throw the stamps off the page.

Frequently Asked Questions

Which placeholders are supported, and how are they written?

Four, in lowercase and inside curly braces: {page} is the page's position in the document, {total} is the document's page count, {date} is today's date in the format chosen in the settings, and {filename} is the name of the file you uploaded with the .pdf extension removed. They can appear anywhere in a slot and more than once, so "{filename} — page {page} of {total}" works exactly as written. Anything else in braces is drawn literally, and so is whatever a placeholder expands to: a file called bud$$et.pdf draws as bud$$et, and one whose name happens to read {page} draws as {page} rather than turning into a page number.

Does {total} count the whole document or only the pages I selected?

The whole document, always. If you stamp pages 3 to 20 of a 24-page report, page 3 reads "page 3 of 24", not "page 1 of 18". This is deliberate — a reader holding the file counts every sheet — but it does mean that skipping a cover does not renumber anything. To restart numbering you have to physically separate the sections with Split PDF, run this tool on the body alone, and reassemble with Merge PDF.

Why is the text placed against the CropBox rather than the page size?

Because they are frequently not the same rectangle. A file exported for print carries a MediaBox a few millimetres larger than the finished page so that artwork can bleed off the edge, and the CropBox marks the part a reader shows. Measuring a 10 mm footer margin from the MediaBox on such a file puts the text into the bleed area, where it looks wrong on screen and gets trimmed off on press. Everything here is measured from the CropBox, after two corrections the format makes necessary: the corners of a PDF rectangle can be stored in either order, so the box is normalised, and a CropBox only counts where it overlaps the MediaBox, so the two are intersected. That is what a reader does — it is how the preview on this page is computed as well — and it means a back-to-front or oversized CropBox still gets stamps on the visible page rather than off it. Ordinary files with no CropBox at all fall back to the MediaBox.

What happens on landscape or rotated pages?

Each page's /Rotate value is read first, the six slot positions are worked out in the orientation the reader will display, and the result is mapped back into unrotated page coordinates with a matching text rotation. A page flagged 90 degrees gets its footer along the edge that appears at the bottom on screen, the right way up, rather than running down one side. Values are normalised the way readers normalise them, on the number exactly as written: -90 becomes 270, 450 becomes 90, and anything that is not an exact multiple of 90 — 45, or a stray 90.4 — is treated as zero, because that is what readers display. Stamping such a page at its nominal angle would put six diagonal strings across a page everyone sees upright. A rotation inherited from the page tree rather than written on the page itself counts the same. Some files break the rule further and store /Rotate as text — /Rotate (90) instead of /Rotate 90. Readers coerce that rather than reject it, and since the preview here is drawn by one of them, the page has already been shown turned; it is read the same way so that the download matches what you were looking at, and the confirmation message says how many pages needed it. Only a value that is not an angle under any reading falls back to upright, which the message reports separately.

My header text is cut off or overlaps the centre slot.

Nothing is measured for collisions or wrapped onto a second line — each slot is drawn as a single run of text from its anchor point. A long left slot will run into a centre slot, and a long right slot will start before the margin and can extend past the page edge. Shorten the text, drop the font size, or move one of the strings to the other band. The preview shows the real geometry, so a clash is visible before you download.

The preview shows no header or footer on the page I am looking at.

Then that page is not one of the pages you have chosen to stamp, and it is being shown as it will be left. The preview answers the question you are actually asking it — what will this page look like afterwards — so it applies the page selection as well as the geometry: tick “skip the first page” and page 1 previews bare, set the range to 5-9 and pages 1 to 4 preview bare, and a message under the page says which of those it is. Switch to a page that is in range, or widen the selection, and the stamps reappear. While the range box is still empty nothing is selected yet, so every page previews bare until you type one.

It refused to run and named characters it cannot draw.

The three fonts offered here are among the fourteen standard fonts every PDF reader ships with, which is why nothing needs to be embedded. The price is their character set: they cover WinAnsi, which is Latin-1 plus a handful of typographic extras. Western European accents such as é, ü, ñ and å are fine, as are curly quotes, en and em dashes and the euro sign. Anything else is not, and the list is longer than people expect: emoji, Greek, Cyrillic, Arabic, Hebrew and CJK, but also the Central and Eastern European Latin letters — Polish ł and ą, Czech ř, Hungarian ő, Romanian ș — and invisible characters, of which a tab pasted in from a spreadsheet is the one people hit. A pasted line break is dealt with before the check rather than by it: a slot holds one line, so each break goes in as a space and a note says so. The message names the slot at fault and lists every character in it the fonts cannot draw, each with its Unicode code point; invisible ones are described rather than printed, so a tab reads "a tab (U+0009)". Nothing is written to the file when this happens — the check runs before any ink is placed, so there is no half-stamped download. Note that {filename} counts as part of the slot's text, so a document whose own name carries one of these letters is refused until you edit the slot or rename the file. Substitute the character, or add the text as an image with PDF Editor.

Can the header and footer be removed later?

Not cleanly. The text is appended to each page's content stream and from that moment is indistinguishable from anything else printed on the page — there is no separate layer to peel off. Keep the unstamped original; re-running this tool is quick, undoing it is not. Running it twice by accident gives you two overlapping headers rather than a replacement.

Is anything uploaded?

No. The document is read with the File API, previewed by a pdf.js worker served from this site, stamped in memory by pdf-lib and saved to your downloads folder as header-footer-yourfile.pdf. No network request carries your file. The one document that will not work is an encrypted one, because it cannot be parsed — run Unlock PDF first.