mPDF Manual – What Else Can I Do

Replaceable Aliases

There are several placemarkers you can include, which will be replaced when the PDF file is ouput:

{nb​}

Will be replaced by the total number of pages in the document. This disregards any changes you make to page numbering with AddPage() or <pagebreak> and will always return the actual number of pages in the PDF document. You can change this alias (in case you wish to use the text {nb​} in your document) using AliasNbPages(). The alias is case-sensitive.

{nbpg​}

Will be replaced by the total number of pages in the document or page group. If you have reset the page numbering with AddPage() or <pagebreak> the total number of pages in the current page group will be used (up to where the numbering is reset) rather the total number of pages in the whole document. You can change this alias (in case you wish to use the text {nbpg​} in your document) using AliasNbPageGroups(). The alias is case-sensitive.

The numbering style can be changed using AddPage() or <pagebreak>.

{PAGENO}

Will be replaced by the Page number - but only in headers/footers. If you have reset the page numbering with AddPage() or <pagebreak> the calculated document page number will be used rather the physical PDF document page number. You cannot change this alias. The alias is case-sensitive.

The numbering style can be changed using AddPage() or <pagebreak>.

{DATE d/m/Y}

Will be replaced by today’s date - but only in headers/footers. The alias is case-sensitive. The date format can be defined using any of the values in the PHP function date(). There must be a space after {DATE

Example:

{DATE j-m-Y H:m}
{colsum} {colsum N}

Place in cell inside a table footer i.e. <tfoot><td>. The total of values in the corresponding column will be output at the bottom of every page, and the end of the tale. Default output is an integer. An optional integer N after colsum will specify a fixed number of decimal places. (mPDF ≥ 5.4)

{iteration varName}

Place in cell inside table header i.e. <thead><td>. You can use any alphanumeric string as a unique varName. (When processed by mPDF it will be replaced by "__varname_" to avoid collision with an mPDF internal variable. The length of the alhanumeric string will determine the length of the placeholder used to space the text i.e. if your counter will reach 1000 you should use a string of at least 4-5 characters in length.

See Also

  • 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}
  • Page numbering
  • aliasNbPg - Specify the text to be replaced by the document page total
  • aliasNbPgGp - Specify the text to be replaced by the group page total
  • iterationCounter - Allow use of {iteration varname} in THEAD
Fork me on GitHub