PHP调用前要先引用命名空间:use Mpdf\Mpdf;
下面是示例:
$mpdf = new Mpdf(['autoScriptToLang' => true, 'autoLangToFont' => true, 'setAutoTopMargin' => 'stretch', 'autoMarginPadding' => 3, 'format' => 'A4', 'orientation' => 'P', 'adjustFontDescLineheight' => 1.4]);
$mpdf->watermark_font = 'Sun-ExtA';
$mpdf->SetWatermarkText('这里是水印内容', 0.1);
$mpdf->showWatermarkText = true;
$header = '<div style="width:100%;clear:both"><div style="width:50%;float:right;text-align:right"><img src="页眉右上角的LOGO" style="margin-top:-10px" height="45"></div><div style="width:50%;float:left;text-align:left">页眉左上角的文字</div></div>';
$mpdf->SetHTMLHeader($header);
$mpdf->SetHTMLFooter('<div style="text-align:center">{PAGENO}/{nbpg}</div>');
$mpdf->WriteHTML('这里是PDF内容,支持HTML。');
ob_end_clean();
$mpdf->Output('下载文件名.pdf', 'D');