Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mpdf no output and php errors in mpdf.php

Tags:

cakephp

mpdf

I'm trying to generate a pdp file in a cakephp application. Therefore, I use the mpdf library as a vendor. But when I try to make a even very simple output it doesn't work. Then when I use the debug property, it shows php errors in the mpdf.php file.

Here is my source code:

<?php
$mpdf=new mPDF();
$mpdf->WriteHTML('hello');
$mpdf->debug = true;
$mpdf->Output();
exit;
?>

And these are the errors shown in the browser:

Notice (8): Undefined index: BODY [APP\vendors\MPDF54\mpdf.php, line 14242]

Notice (8): Undefined index: BODY>>ID>> [APP\vendors\MPDF54\mpdf.php, line 14288]

Notice (8): Undefined offset: -1 [APP\vendors\MPDF54\mpdf.php, line 14421]

Thank you for your help!

like image 369
Vestrep Avatar asked Sep 25 '26 05:09

Vestrep


1 Answers

This is not a CakePHP problem but related to the library you're using.

Read about how to use the WriteHTML() method. http://mpdf1.com/manual/index.php?tid=121

And try passing 2 as the 2nd argument.

$mpdf->WriteHTML('hello', 2);

If this still does not work read the documentation, check the examples there.

like image 80
floriank Avatar answered Sep 28 '26 13:09

floriank



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!