change top margin of second page using mPDF

廉价感情. 提交于 2020-12-08 07:34:10

问题


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?

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

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

回答1:


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

define the margins using @page like:

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


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



回答2:


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

define the margins using @page like:

@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




回答3:


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

Reference: Mpdf documentation



来源:https://stackoverflow.com/questions/16538109/change-top-margin-of-second-page-using-mpdf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!