mPDF Manual – Getting Started

Creating your first file

The following PHP will produce the most basic example with mPDF ≥ 7.0.

<?php
// Require composer autoload
require_once __DIR__ . '/vendor/autoload.php';
// Create an instance of the class:
$mpdf = new \Mpdf\Mpdf();

// Write some HTML code:
$mpdf->WriteHTML('Hello World');

// Output a PDF file directly to the browser
$mpdf->Output();

Note: For mPDF < 7.0 use $mpdf = new \mPDF();

Notes

For details and options for the Output() method, see  Output().

Fork me on GitHub