SetHeader()
(mPDF ≥ 1.0)
SetHeader – Sets a page header
Description
void SetHeader ([ mixed $header [, string $side [, boolean $write ]]])
Set a page header.
Note: This function/method was altered in mPDF 2.2 by capitalising the first letter of the name. As function/method names in PHP have hitherto been case-insensitive, this should not cause any problems, but it is recommended where possible to use the preferred spelling.
Parameters
- $header
-
This parameter specifies the content of the page header. It can accept a string or array.
Default:
array()
- Values
''
(BLANK string) ornull
orarray()
- This will clear the page header.
TEXT STRING
- A simple text string is set as content for the RIGHT margin. If
DOUBLE-SIDED document, this is mirrored on EVEN
pages i.e. LEFT margin.
If a text string containing 2 characters
|
, it will be split into three strings and set as content for, respectively, theleft | centre | right
parts of the headere.g.
$header = 'Chapter 1|{PAGENO}|Book Title'
.If DOUBLE-SIDED document, this is mirrored on EVEN pages i.e.
right|centre|left
. ARRAY
- An array can be in two forms:
-
(Deprecated) The first form includes information for both ODD and EVEN headers, and is the expected form if $side = BLANK.
Values
'odd'
: subarray for ODD-
'even'
: subarray for EVENSubarray with following entries:
'L'
: subarray for left'C'
: subarray for center-
'R'
: subarray for rightSubarray with following entries:
'content'
: TEXT STRING'font-size'
: FLOAT font size in pts'font-style'
:B
|I
|BI
| BLANK STRING'font-family'
: Any available font-family'color'
: CSS#RRGGBB
string
'line'
:0
|1
- specify whether to draw a line above the Header
Example:
<?php $header = array ( 'odd' => array ( 'L' => array ( 'content' => '', 'font-size' => 10, 'font-style' => 'B', 'font-family' => 'serif', 'color'=>'#000000' ), 'C' => array ( 'content' => '', 'font-size' => 10, 'font-style' => 'B', 'font-family' => 'serif', 'color'=>'#000000' ), 'R' => array ( 'content' => 'My document', 'font-size' => 10, 'font-style' => 'B', 'font-family' => 'serif', 'color'=>'#000000' ), 'line' => 1, ), 'even' => array () );
-
The second form includes information for either ODD or EVEN headers, and must be accompanied by a valid value for $side =
'O'
|'E'
Example:
<?php $header = array ( 'L' => array ( 'content' => '', 'font-size' => 10, 'font-style' => 'B', 'font-family' => 'serif', 'color'=>'#000000' ), 'C' => array ( 'content' => '', 'font-size' => 10, 'font-style' => 'B', 'font-family' => 'serif', 'color'=>'#000000' ), 'R' => array ( 'content' => 'My document', 'font-size' => 10, 'font-style' => 'B', 'font-family' => 'serif', 'color'=>'#000000' ), 'line' => 1 );
-
- $side
-
Specify whether to set the header for ODD or EVEN pages in a DOUBLE-SIDED document.
Default: BLANK
Values (case-sensitive)
O
- set the header for ODD pagesE
- set the header for EVEN pages- BLANK - sets both ODD or EVEN page headers
- $write
-
If
true
, it forces the Header to be written immediately to the current page. Use if the header is being set after the new page has been added.Default:
false
Note: $write forces the appropriate header to be written. If you have just defined an ODD-sided header and the document is currently writing to an EVEN-sided page, the EVEN header will be output.
Changelog
Version | Description |
---|---|
2.0 | The $side and $write parameters were added. |
Examples
For examples and further information please see: