php 使用 mPDF 更改第二页的上边距

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16538109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 11:19:47  来源:igfitidea点击:

change top margin of second page using mPDF

phpmpdf

提问by Paul Dessert

I'm dynamically generating PDFs with an unknown page count. mPDF is working good, but the top margin on the second page is gone. How can I set the margins for all pages with the document?

我正在动态生成页数未知的 PDF。mPDF 运行良好,但第二页的上边距消失了。如何为文档的所有页面设置边距?

I've tried the following, but it has no effect:

我尝试了以下方法,但没有效果:

$mpdf = new mPDF('', '', 0, '', 15, 15, 15, 15, 8, 8);

回答by Srihari Goud

You can use something like this. it seems to work.

你可以使用这样的东西。它似乎工作。

define the margins using @page like:

使用@page 定义边距,例如:

<?php
    include("mpdf.php");
    $html='<style>@page {
     margin: 0px;
    }</style>


    ';
    $mpdf=new mPDF('','A4');
    $mpdf->WriteHTML($html);
    $mpdf->Output();
    ?>

回答by Paul Dessert

I was able to find an answer. Here it is in case anyone needs it:

我找到了答案。这是以防万一有人需要它:

define the margins using @pagelike:

使用@page如下定义边距:

@page *{
    margin-top: 2.54cm;
    margin-bottom: 2.54cm;
    margin-left: 3.175cm;
    margin-right: 3.175cm;
}
</style>';

Reference: http://www.mpdf1.com/forum/discussion/80

参考:http: //www.mpdf1.com/forum/discussion/80

回答by Santiago Bernal

$mpdf->AddPage('L','','','','',50,50,50,50,10,10);

Reference: Mpdf documentation

参考:Mpdf 文档