mPDF Manual – HTML support

HTML Attributes

HTML tag Attributes (in-line) supported

Example of an HTML attribute: <div $align=”center”>

mPDF supports attribute values in single or double quotes e.g. <div align=”center”> or <div align=’center’>

Minimised attributes are not supported e.g. <input type=”checkbox” disabled />

XHTML specification is recommended for best compliance with mPDF.

HTML, BODY and ALL recognised tags lang* LANGUAGE-COUNTRY CODE *
dir rtl | ltr   (mPDF >= 6.0)
HTML, BODY dir rtl | ltr  (mPDF >= 5.0)
P, DIV align left | center | right | justify
TABLE        border 1 | 0
width LENGTH
align left | center | right | char char was added in mPDF 5.7
char Used in conjunction with align="char". Default if omitted is period "." Non-ASCII characters can be defined with HTML entities e.g. &middot; or &#183; As per HTML 4 spec. Added mPDF 5.7
bgcolor #rrggbb
cellSpacing LENGTH
cellPadding LENGTH
*(repeat_header)* 1   (removed from mPDF >= 5.4; use <thead>)
*autosize* FLOAT  value >= 0 Shrinks a table to fit if width is too small to allow complete words to fit. The value (must be >=1) determines the maximum allowable factor to shrink i.e. autosize="2" will allow the font-size to be reduced to a minimum of 1/2 the original size. A value of 1 prevents automatic resizing of the table. (custom attribute)
*rotate* 90 | -90
TR bgcolor #rrggbb
TD, TH      width LENGTH
height LENGTH (but not %)
align left | center | right
valign top  |middle | bottom
bgcolor #rrggbb
colspan INTEGER
rowspan INTEGER
nowrap nowrap
OL, UL font-size FONT-SIZE
OL type 1 | A | a | I | i | disc | circle | square
start INTEGER (mPDF >= 5.7)
UL type disc | circle | square
IMG width, height LENGTH
max-height, max-width, min-height, min-width LENGTH
*rotate* 90 | -90 | 180 90 = clockwise When width is specified e.g. width="3cm" this is applied to the rotated image i.e. will be width 3cm after rotating
HR  width nn%
align left | center | right
color #rrggbb
size 1 | 2 | 3 | 4 | 5 | 6 | 7 | -1 | +1
color #rrggbb
FORM method get | post  (default=post)  (mPDF >= 5.3)
action URI  (mPDF >= 5.3
readonly readonly
required required  [HTML5] (mPDF >= 5.3)
spellcheck true | false [HTML5] Default=false (mPDF >= 5.3)
onChange JAVASCRIPT In Active Forms; uses "Acrobat" Javascript (mPDF >= 5.3)
TEXTAREA, SELECT, INPUT disabled disabled
title TEXT
name TEXT   Field names in Active Forms must only contain letters, numbers, colon(:), undersore(_) or hyphen(-). (This is largely as per HTML spec, but cannot contain period(.) as this is part of PDF spec for name heirarchies)
SELECT size INTEGER size = n rows visible. Default=1
multiple multiple
required required [HTML5] (mPDF >= 5.3)
spellcheck true | false [HTML5] Default=false (mPDF >= 5.3) Only if also editable and size=1
editable editable  [HTML5] Default=false (mPDF >= 5.3) Only if size=1
onChange JAVASCRIPT In Active Forms; uses "Acrobat" Javascript (mPDF >= 5.3)
OPTION selected selected
value TEXT
INPUT type text | password | hidden | image | button | submit | reset | radio | checkbox
INPUT (text, password, hidden, image, button, submit, reset) size INTEGER size=n=width as number of characters
value TEXT
INPUT (text, password) maxlength INTEGER
readonly readonly
required required [HTML5] (mPDF >= 5.3)
spellcheck true | false [HTML5] Default=false (mPDF >= 5.3)
onChange JAVASCRIPT In Active Forms; uses "Acrobat" Javascript (mPDF >= 5.3)
INPUT (image, button, submit, reset) alt TEXT
src TEXT
onClick JAVASCRIPT In Active Forms; uses "Acrobat" Javascript (mPDF >= 5.3)
INPUT (button, submit, reset) *noprint* noprint (mPDF >= 5.3)
INPUT (radio, checkbox) value TEXT In Active Forms value(s) for radio buttons and checkboxes are required, and can only contain letters, numbers, colon(:), undersore(_), hyphen(-) or period(.)
DOTTAB *outdent* LENGTH (mPDF >= 5.7)
METER value, max, min, low, high, optimum FLOAT [HTML5 spec]
PROGRESS value, max FLOAT [HTML5 spec]
*type* Any alphanumeric string. If present, will select custom progress/meter formats - IF they have been defined by the user by editing script classes/meter.php
  • $lang is only recognised when the variable $useLang is set to TRUE (DEFAULT is TRUE)


2.0 TD border="1" was supported <= mPDF 1.3, but is not valid HTML and is now ignored
  TABLE align="..." with a rotated table - changed to set the alignment ignoring the rotation i.e. align=right sets the table to the right side of the page (looking as though it is bottom-aligned)
2.3 $lang was added.
4.0 Default value of $lang changed to TRUE
5.0 $dir was added to HTML and BODY