mPDF Manual – Paging

# Page numbering

{PAGENO} in a header or footer will be replaced by the document page number. By default this will be the actual page number in decimal numerals.

You can optionally:

• suppress page numbering - {PAGENO} will be replaced by a blank string - but counting will continue
• reset numbering - reset the numbering anywhere in the document
• define/change the style of the numbering - as for lists it can be roman, alphabetical or decimal

From mPDF >= 3.0 the page numbering can be reset to any positive number. Prior to this, it was only possible to reset it to 1.

From mPDF 6.0 the page number style can include any of the values used for list-style-type

Page numbering changes are made when adding a new page using AddPage() or <pagebreak> (or TOCpagebreak() and  <tocpagebreak>) or using @page.

You could obviously also hide the page numbering by redefining a header or footer that does not include {PAGENO}.

### Changing page numbering from the start of the document

If you want to set page numbering characteristics from the first page onwards, you should explicitly add the first page of the document using AddPage(). Note that this is normally not required, as mPDF creates a new first page automatically if required when first using WriteHTML().

### Example #2

In a complex document you could suppress the page numbering from the start for the cover page(s); then reset the number to 1, and set the style as lowercase Roman (i,ii,iii) for the foreword and introduction; then reset the style to decimal for the rest of the document:

If using the initial  AddPage() causes problems (a blank first page), an alternative way to do this is:

# See Also - defaultPageNumStyle - Specify a default page numbering style from the start of the document - pagenumPrefix - Specify text to precede page numbers generated by {PAGENO} - pagenumSuffix - Specify text to follow page numbers generated by {PAGENO} - nbpgPrefix - Specify text to precede page total generated by {nbpg} - nbpgSuffix - Specify text to follow page numbers generated by {nbpg} - Replaceable aliases - aliasNbPg - Specify the text to be replaced by the document page total - aliasNbPgGp - Specify the text to be replaced by the group page total Please also see Table of Contents for this special case.