I have downloaded the updated version of mpdf and using it with php. It is giving me the following error.

"fatal error: Trait 'Mpdf\Strict' not found in E:\xampp\htdocs\PDF\mpdf\Mpdf.php on line 39".

$html = '<h2>mpdf test.</h2>';

include("mpdf/mpdf.php");

$mpdf = new mPDF('c','A4','','',32,25,27,25,16,13); 

$mpdf->SetDisplayMode('fullpage');

$mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first 
 level of a list

// LOAD a stylesheet
$stylesheet = file_get_contents('mpdfstyletables.css');
$mpdf->WriteHTML($stylesheet,1);    // The parameter 1 tells that this is css/style only and no body/html/text

$mpdf->WriteHTML($html,2);

$mpdf->Output('mpdf.pdf','I');
exit;

1 Answers

2
SaschaM78 On Best Solutions

You are directly including mpdf via

include("mpdf/mpdf.php");

which will only include the core file but not any other file mPDF may need in the generation process. The correct way would be to use:

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

This will make sure that required classes will be autoloaded as soon as they are referenced.

For more info, check the "Getting started" chapter on the mPDF web page.