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.

Leave a Reply

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