Movatterモバイル変換


[0]ホーム

URL:


mPDF Manual – Headers & Footers

Headers & Footers

Page headers and page footers can be set for mPDF documents in a number of different ways. As mPDF has evolved, newmethods have been added.

Warning: Use of CSS @page selector with any content will rewrite/remove headers not defined in the selector. See@page selector documentation.

Note: As from mPDF v6.0 Headers and Footers are all now written internally as HTMLheaders/footers.

Theuse of non-HTML headers and footers (methods 1 & 3) is deprecated, but remains supported. Non-HTML headers and footers are converted in mPDF to HTML equivalents.

Default non-HTML headers will not clash with HTML headers, but named non-HTML headers WILL clash with (and overwrite) HTML headers of the same (equivalent) name e.g.MyFooter (non-HTML)overwriteshtml_MyFooter (HTML).

Note: As from mPDF v7.1 Headers and Footers supportabsolute positioning, howeveryou cannot use both absolute and non-absolute positioned content together in the Headers and Footers.

Types

RUNTIME
RUNTIME headers/footers are set as they are required throughoutthe document.
NAMED
NAMED headers/footers are defined at any time (before they are used) andgiven a ‘name’; they can then be used/re-used by reference to that name at any time. They can be defined by either PHPscript or custom HTML tags.
Non-HTML
(deprecated)NON-HTML headers/footers are set by text strings with no HTML mark upto define styles. Style changes (font-size, font-family, color) can be defined by changing mPDF variables.
HTML
HTML headers/footers are written in standard HTML code. They can only bedefined outside HTML block tags (except<body>).

Note:HTML headers/footers are more intensive of processing time and memory. This probably makes little difference for an average/short document, but may be important for long/complex documents.

Methods

  NON-HTMLHTML
RUNTIME

Method 1 (deprecated)

This is the simplest & quickest way to define a header/footer for the whole document if you need limited control over styling.

SetHeader()SetFooter() There are several variants of this method, using string or array. The simplest form does not allow different header/footer forODD andEVEN pages.

Style can be defined by variables:

$defaultheaderfontsize$defaultheaderfontstyle$defaultheaderline$defaultfooterfontsize$defaultfooterfontstyle$defaultfooterline

Method 2

The simplest & quickest way to program a header/footer once for the whole document that includes images or uses more complex layout styles.

SetHTMLHeader()SetHTMLFooter()

NAMEDDefine

Method 3 (deprecated)

This method is useful if you do not need the flexibility of an HTML header/footer, but are changing headers/footers throughout the document.

DefHeaderByName()DefFooterByName() <pageheader> <pagefooter>

Method 4

This is the best way for complex headers/footers with the advantage of HTML code, but you can easily change the headers/footers at any time during the document.

DefHTMLHeaderByName()DefHTMLFooterByName() <htmlpageheader> <htmlpagefooter>

Reference

These methods are recommended when setting the header/footer at thestart of a document.

SetHeaderByName()SetFooterByName() <setpageheader> <setpagefooter>@page

These methods are recommended when setting the header/footer at thestart of a document.

SetHTMLHeaderByName()SetHTMLFooterByName() <sethtmlpageheader> <sethtmlpagefooter>@page

Recommended when you wish to change the headers/footersduring the document. These methods can reference anyNAMED header or footer (NON-HTML orHTML)

AddPage()

TOCpagebreak() <pagebreak> <tocpagebreak>@page

In any of the options,{PAGENO} or{DATE j-m-Y} can be used - which will be replaced by the page number or current date.j-m-Y can be replaced by any of the valid formats used in the PHPdate() function.

See also


[8]ページ先頭

©2009-2026 Movatter.jp