mpdf (4.0k ⭐) is a library to create PDF files.

$ composer require mpdf/mpdf

You can use the given code sample to test your installation.


require_once __DIR__ . '/vendor/autoload.php';

$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML('<h1>Hello world!</h1>');

Example using a heredoc and downloading a file:

$mpdf = new \Mpdf\Mpdf();
<!-- you can use PHP variables and there is no need to
escape quotes within a HEREDOC clause -->
// Download the PDF as a file, close the tab