mPDF Manual – About mPDF

Features

Main features (as of version 7)

  • Accepts UTF-8 encoded HTML
  • Supports almost all languages including RTL (arabic and hebrew), and CJK - (chinese-japanese-korean)
  • Bookmarks
  • CSS stylesheets
  • Word spacing and character spacing for justification
  • Nested block-level elements (e.g. P, DIV) including margins, borders, padding, line-height, background colours etc.
  • Support (partial) for floating and fixed-position block-elements
  • Page layout and orientation
  • Text-justification and hyphenation
  • Page numbering
  • Odd and even paging with mirrored margins
  • Page headers & footers
  • Columns
  • Tables - nested tables, rotated, or autosized to fit on a page
  • Table of contents
  • Index
  • Watermarks (with customizable text angle)
  • Images in JPG, GIF, PNG, SVG, BMP or WMF format
  • Password protection
  • Annotations
  • Barcodes (EAN13, UPC-A/E, Code 11, 39, 93, 128, Codabar, MSI, IMB, Planet, Postnet, RM4SCC etc.)
  • Import another PDF file and use as a template
  • Embedded font subsets
  • PDF/A-1b support (ISO 19005-1:2005)
  • PDF/X-1a support
  • PDF/A-3 support (along with ZUGFeRD invoices compatibility)

More Information

mPDF has a number of enhancements over the original FPDF, HTML2FPDF and UPDF scripts:

UTF-8 encoded HTML is accepted as the standard input.

Right-to-left languages are supported, with automatic detection of RTL characters within a document. Transposes: tables, lists, text justification and table cell alignment, as well as full text reversal for RTL characters. Automatically detects non-RTL characters and displays these in original order.

Bookmarks and Meta tag information are supported in all character sets.

A single CSS stylesheet can be used for all pages, with font substitution automatically for CJK characters.

Character substitution can optionally be used to automatically replace any characters that do not exist in the current font. Word spacing and character spacing are both used to justify text; works in unicode mode and CJK characters as well.

Nested block-level elements (e.g. P, DIV) are supported, with comprehensive CSS support e.g. margins, borders, padding, line-height, background colours etc.

CSS style attributes now fully support font, font-size, color, and background color (for highlighting) plus many more.

Table cell padding and borders are supported.

Text-indent for 1st line of paragraph and hanging indents are supported.

List indenting can be defined.

Custom tags added - PAGEBREAK, COLUMNBREAK, INDEXENTRY

Multiple columns can be started and stopped anywhere on the page with column height adjusted (and optionally aligned to justify).

Tables can be rotated, or autosized -  font-size is reduced if required to fit the page. Background colour for TR rows is supported.

Odd and even paging can be used with inner and outer margins alternated.

A more complex definition of headers and footers allows left/center/right parts to be defined, each with their own font-styles, and including code to allow the date/time to be inserted as well as page numbers.

A table of contents can be generated automatically, which can be inserted at the front of the document, based on custom tags used throughout the HTML code. (Based on Richard Bondi’s extension to FPDF.)

An Index can be generated at the end of the document based on custom tags used throughout the HTML code.

Non-breaking space is supported when using fonts that have a character representing chr(160) (not all of them). 

Watermarks as text or images can be used e.g. for ‘DRAFT’, and will appear as a transparency over other elements.

Intelligent word-wrapping will avoid ‘orphan’ punctuation or superscript moving to the next line.

Automatic hyphenation is optional.

All HTML entities are supported, as well as decimal and hex e.g. '≬ or ↤

Password protection can be set for the PDF file.

NB The original commands from FPDF can be used e.g. Write(), but some are altered to allow UTF-8 encoding and RTL text to be processed e.g. use WriteCell() and WriteMultiCell() instead of Cell() and MultiCell().

Fork me on GitHub