我mpdf
在PHP中使用库来从HTML创建pdf文件.我需要在landscape
模式下设置页面模式.
这是我正在使用的代码:
$mpdf=new mPDF('c'); $mpdf->WriteHTML($html); $mpdf->Output(); exit;
但是,这是在portrait
模式下设置页面模式.任何想法,如何在mpdf中设置横向模式?
您可以通过在页面格式中添加-L来实现.所以在我们的例子中你要为你的构造函数添加另一个参数:
$mpdf = new mPDF('c', 'A4-L');
有关mPDF构造函数参数的更多信息,请参见此处
这可能对您有用.
最后一个参数是方向.
class mPDF ([ string $mode [, mixed $format [, float $default_font_size [, string $default_font [, float $margin_left , float $margin_right , float $margin_top , float $margin_bottom , float $margin_header , float $margin_footer [, string $orientation ]]]]]])
P:DEFAULT肖像
L:风景
"-L"强制执行Landscape页面方向
// Define a Landscape page size/format by name $mpdf=new mPDF('utf-8', 'A4-L'); // Define a page using all default values except "L" for Landscape orientation $mpdf=new mPDF('','', 0, '', 15, 15, 16, 16, 9, 9, 'L');
你可以在这里挖掘更多
检查mPDF构造函数的文档.
$mpdf=new mPDF('c', 'A4-L');
添加这样的选项:
$mpdf = new mPDF('', // mode - default '' '', // format - A4, for example, default '' 0, // font size - default 0 '', // default font family 15, // margin_left 15, // margin right 16, // margin top 16, // margin bottom 9, // margin header 9, // margin footer 'L'); // L - landscape, P - portrait