Tag Archives: Mpdf

How to repeat the header on every page in mpdf ?

pdf_mpdf

If you want to add header in your custom mpdf and repeat the header for every page on mpdf then simply put the below code in your code and you can get the dynamic header in your generated pdf.

Step 1)

put the below code to your mpdf.

<htmlpageheader>
             {Header title}
</htmlpageheader>
<sethtmlpageheader name="MyHeader1" value="on" show-this-page="0" />

How to Work Mpdf Workable in Php 7 ?

pdf_mpdf

If you use an old version of PHP in your local system and you integrate the mpdf in that old version. after you change your PHP version to the latest version and mpdf is not working then simply follow our below steps and you will get the mpdf working in your latest PHP version.

Step 1)

Click here to download the mpdf.

Step 2)

Include the mpdf

require_once _DIR_ . ‘/MPDF/vendor/autoload.php’;

instead of

require_once( ‘mpdf/mpdf.php’);

Step 3)

Just change your code to

$html = “Your html code here”;
$mpdf = new \Mpdf\Mpdf([‘mode’ => ‘utf-8’, ‘format’ => ‘A4′,’0′,”,0,0,0,0,’margin_header’ => 0,’orientation’ => ‘P’]);
$mpdf->setAutoTopMargin = ‘stretch’;
$mpdf->setAutoBottomMargin = ‘stretch’;
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;

Instead of

$html = “Your html code here”;
$mpdf=new mPDF(‘utf-8’, ‘A4’, 0, ”, 0, 0, 0, 0, 0, ‘P’);
$mpdf->setAutoTopMargin = ‘stretch’;
$mpdf->setAutoBottomMargin = ‘stretch’;
$mpdf->WriteHTML($stylesheet, 1);
$mpdf->WriteHTML($html);
$mpdf->Output();

Step 4)

Now your mpdf is working in php 7 and above version.