1

I am trying to install the magento2-pdf-generator2 extension, but I first need to install the mpdf library, I ran the composer require mpdf/mpdf command and then ran php bin/magento setup:upgrade and php bin/magento setup:static-content:deploy to clear the caches.

I tried the following example example and put it in a file called test1.php in the root directory:

require_once __DIR__ . '/vendor/autoload.php';

$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML('<h1>Hello world!</h1>');
$mpdf->Output();

But I am getting an error:

[31-May-2017 16:30:00 UTC] PHP Fatal error:  Uncaught Error: Class 'Mpdf\Mpdf' not found in /home/public_html/test1.php:4
Stack trace:
#0 {main}
  thrown in /home/public_html/test1.php on line 4

all that I have in my test file is:

<?php
require_once __DIR__ . '/vendor/autoload.php';

$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML('<h1>Hello world!</h1>');
$mpdf->Output();
?>

I do have the mbstring, gd, zlib and bcmath extensions enabled. I am unsure why it isn't loading

2 Answers 2

1

try code below

$mpdf = new \mPDF('utf-8', 'A4-L');
0
0
composer require mpdf/mpdf
php bin/magento setup:upgrade
For Magento version 2.0.x to 2.1.x - php bin/magento setup:static-content:deploy
For Magento version 2.2.x & above - php bin/magento setup:static-content:deploy –f
php bin/magento cache:flush

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.