Open main menu


MediaWiki extensions manual
Crystal Clear action run.svg
Release status: beta
Implementation Parser function
Description Converts current page to PDF and sends it to the browser
Author(s) Pavel Astakhov (pastakhovtalk)
Latest version 0.9.0 (2018-06-13)
MediaWiki 1.25+
PHP 5.4+
Database changes No
License GNU General Public License 2.0 or later
Hooks used
Translate the Mpdf extension if it is available at
Check usage and version matrix.

The Mpdf extension lets you export the printable version of a page as a PDF file. To do so it uses uses the "mPDF PHP class" in version 6.1 for HTML to PDF conversion.

  • no need to install additional components
  • the generated PDF uses the same CSS styles as for rendering the printable version of the page
  • small size of the PDF file
  • supports UTF-8
About mPDF

mPDF is a PHP class which generates PDF files from UTF-8 encoded HTML. It is based on FPDF and HTML2FPDF, with a number of enhancements.



The PDF creation is initialised by the mpdf action, so a page can be downloaded as a PDF file directly from a link such as:

A more generic way of creating the link is to use the "fullurl" parser function and the FULLPAGENAMEE built in variable as in the following example.

[{{fullurl:{{FULLPAGENAMEE}}|action=mpdf}} download this page as a PDF file]

This link can then be added to a template which can be transcluded into any page for downloading as a PDF file.


Use parser function {{#mpdftags: ... }} to add tags specified in documentation of mpdf class.

pageheader name="MyHeader1" content-left="" content-center="" content-right="My document" header-style="font-family: serif; font-size: 10pt; font-weight: bold; color: #000000;" line="on" |
 pagefooter name="MyFooter1" content-left="{DATE j-m-Y}" content-center="{PAGENO}/{nbpg}" content-right="My document" footer-style="font-family: serif; font-size: 8pt; font-weight: bold; font-style: italic; color: #000000;"

setpageheader name="MyHeader1" value="on" show-this-page="1" |
setpagefooter name="MyFooter1" value="on"

Raw HTML outputEdit

You can download the file as a single HTML document by setting format=html in the query-string.



  • Make sure that you provide the following required PHP modules:
    • gd
    • mbstring
    • zlib
  • Download and place the file(s) in a directory called Mpdf in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'Mpdf' );
  • Download, extract and place the Mpdf files in a directory called mpdf in your extensions/Mpdf/ folder.
  • Ensure that you have write permissions set for the following subfolders of $IP/extensions/Mpdf/mpdf:
    • /ttfontdata/
    • /tmp/
    • /graph_cache/
Note the different location when installing from Git (see below)
  • Configure as required
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

To users running MediaWiki 1.31 or earlier:

The instructions above describe the new way of installing this extension using wfLoadExtension() If you need to install this extension on these earlier versions (MediaWiki 1.31 and earlier), instead of wfLoadExtension( 'Mpdf' );, you need to use:

require_once "$IP/extensions/Mpdf/Mpdf.php";
When installing from Git, please note that this extension requires Composer.

So, after installation from Git change to the directory containing the extension e.g. "../extensions/Mpdf/" and run composer install --no-dev, or when updating: composer update --no-dev.

Alternatively as well as preferably add the line "extensions/Mpdf/composer.json" to the "composer.local.json" file in the root directory of your wiki like e.g.
	"extra": {
		"merge-plugin": {
			"include": [

Moreover the following subfolders of $IP/vendor/mpdf/mpdf require write permission for the web server:

  • /ttfontdata/
  • /tmp/
  • /graph_cache/


This extension offers one configuration parameter. It should be set in your "LocalSettings.php" file after the inclusion of the extension.

Whether or not an action tab is wanted for export to PDF (defaults to false)

See alsoEdit