mPDF Manual – Fonts & Languages

Default Font

Default font & font-size

A default font and font-size are required for mPDF to function. These are determined by:

Declared when instantiating the mPDF class (see Getting Started). These “provisional” default values will be active if you are using functions to write directly to the PDF file e.g.

<?php

$mpdf = new mPDF('','A4',9,'dejavusans');

$mpdf->WriteCell(110,5,'Hallo World');

If you are using WriteHTML() these “provisional” default values are overridden, and defaults are set as follows:

  • If mPDF('c') is set, the default font is set as 'helvetica', 'times' or 'courier'
  • Otherwise the default font is set by the value in the default stylesheet `$default_CSS` in config.php
  • NB The default font-*size* is also set by the value in the default stylesheet `$default_CSS`

If the secondary default CSS stylesheet mpdf.css contains values to define the BODY tag, these values will override the above e.g.

body { font-family: serif; font-size: 10pt; }

If a CSS stylesheet is used with WriteHTML() and contains values to define the BODY tag, these values will override the above.

In-line style used in the <body> tag will override the default values e.g.

<body style="font-family: serif; font-size: 10pt;">