How to Work Mpdf Workable in Php 7 ?

How to Work Mpdf Workable in Php 7 ?

How to Work Mpdf Workable in Php 7 ?

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 versions.

0 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *