change top margin of second page using mPDF

Paul Dessert picture Paul Dessert · May 14, 2013 · Viewed 43.5k times · Source

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);

Answer

Srihari Goud picture Srihari Goud · Nov 28, 2013

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();
    ?>