composer require mpdf/mpdf
<?php
require_once __DIR__ . '/vendor/autoload.php';
$mpdf = new \Mpdf\Mpdf([
'orientation' => 'L', //设置为横屏
'margin_top' => '0', //设置上边距
'margin_bottom' => '0' ,//设置下边距
'format' => [190, 236], //纸张大小
'mode' => 'utf-8',
]);
$mpdf->autoScriptToLang = true;
$mpdf->autoLangToFont = true;
$mpdf->use_kwt = false;
$html = "<table style='text-align:center'>
<tr>
<th><h1>Hello world!</h1></th>
</tr>
<tr>
<th><h1>Hello world!</h1></th>
</tr>
<tr>
<th><h1>Hello world!</h1></th>
</tr>
<tr>
<th><h1>Hello world!</h1></th>
</tr>
</table>";
//设置水印文字
$mpdf->SetWatermarkText('Water');
$mpdf->showWatermarkText = true;
//设置水印图片
$mpdf->SetWatermarkImage('./background.jpg');
$mpdf->showWatermarkImage = true;
$mpdf->WriteHTML($html);
$mpdf->Output('mpdf.pdf', 'I'); //D是下载
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。