'MPDF undefined index error
I am using MPDF library to convert HTML to PDF.
Here is my code.
$HTML = '{HTML CONTENT GOES HERE}'; //HTML STRING
$MPDF->WriteHTML($html); // Converting
$MPDF->Output('preview.pdf','F'); //Saving to a File
It works , but generating too much errors in error log ,
ERROR - 2012-11-10 04:45:50 --> Severity: Notice --> Undefined index: BODY C:\wamp\www\crm\application\libraries\mpdf.php 14242
ERROR - 2012-11-10 04:45:50 --> Severity: Notice --> Undefined index: BODY>>ID>> C:\wamp\www\crm\application\libraries\mpdf.php 14288
ERROR - 2012-11-10 04:45:50 --> Severity: Notice --> Undefined offset: -1 C:\wamp\www\crm\application\libraries\mpdf.php 14421
ERROR - 2012-11-10 04:45:50 --> Severity: Notice --> Undefined variable: cstr C:\wamp\www\crm\application\libraries\mpdf.php 31951
ERROR - 2012-11-10 04:45:50 --> Severity: Notice --> Undefined index: DIV C:\wamp\www\crm\application\libraries\mpdf.php 14242
ERROR - 2012-11-10 04:45:50 --> Severity: Notice --> Undefined index: ID>>PRINT_WRAPPER C:\wamp\www\crm\application\libraries\mpdf.php 14280
ERROR - 2012-11-10 04:45:50 --> Severity: Notice --> Undefined index: DIV>>CLASS>>PRINTWRAPPER C:\wamp\www\crm\application\libraries\mpdf.php 14284
ERROR - 2012-11-10 04:45:50 --> Severity: Notice --> Undefined index: DIV>>ID>>PRINT_WRAPPER C:\wamp\www\crm\application\libraries\mpdf.php 14288
ERROR - 2012-11-10 04:45:50 --> Severity: Notice --> Undefined index: DIV C:\wamp\www\crm\application\libraries\mpdf.php 14242
anybody have some working experience with this library ? (If it only outputs some errors then we can fix it by changing on the library , but here it gives too much error) , i think that i am missing something.
Please help me.
Thanks.
Solution 1:[1]
Add following at top of mpdf.php
error_reporting(0);
This will resolved the issue.
Solution 2:[2]
Still found no real solution (has anyone?). As a workaround, I patched mpdf.php directly in nearly 20 places.
Before:
$variable[possible_wrong_index];
After:
(isset($variable[possible_wrong_index]))?$variable[possible_wrong_index]:false;
There are some if-statements, which were trickier. But now I have no errors in the log and the generated pdf seems to be no affected by this.
(I'm aware that this is a hacky workaround, but it works for the moment - the real fun starts with updates of mpdf :)
Solution 3:[3]
I had the very same problem. The HTML code was well formed, but it didn't help.
I modified the class mpdf.php. I added the check, whether the index is set on each reported line.
Like this
if(isset($p[$tag])){
$this->_mergeCSS($p[$tag], $t);
}
Solution 4:[4]
I don´t know exactly why did it happen, but I Had the same problem and I solved it placing the 'include 'MPDFxx/mpdf.php' at the top of the function where I was calling the WriteHTML function. BTW I've found it using MPDF57.
Solution 5:[5]
If table used in html view. than make sure td tag is inside tr tag.
Otherwise mpdf retrns undefined index: l
Solution 6:[6]
You can check for none printable character with this tool:
https://www.soscisurvey.de/tools/view-chars.php
This solved my problem.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Heer Makwana |
| Solution 2 | Rolf |
| Solution 3 | Luboš Mi?atský |
| Solution 4 | user1760477 |
| Solution 5 | mayur vadher |
| Solution 6 | masoud sharifi |
