MPDF undefined index error

undefined index: inherit mpdf
mpdf button
mpdf download pdf
mpdf example
mpdf z-index
laravel mpdf
how to open mpdf
how to use mpdf in php

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.

Is the HTML well formed, and also are all the tags and attributes either all lowercase or all uppercase? Here are the requirements for the HTML as per MPDF documentation:

Example of an HTML attribute: <div align="center">

mPDF supports attribute values in single or double quotes e.g. <div align="center"> or <div align='center'>

Minimised attributes are not supported e.g. <input type="checkbox" disabled />

XHTML specification is recommended for best compliance with mPDF.

Also per https://mpdf.github.io/html-support/html-tags.html

you seem to be using tags that are not supported. BODY for instance is not.

I would try to limit my HTML to the ones on the documented list and and follow their well formed guidelines and see if the errors get fixed that way. They are only 'notices' so nothing severe, but it would be best to fix them just in case future versions are not as forgiving.

Undefined index issue and fix (Undefined index: list_style_image , As noted in the subject error 'Undefined index: list_style_image' was stopping mpdf from printing. With the following check it works as intended. Notice: Undefined index: win-1252 in src/Mpdf.php on line 3741. you might need to suppress NOTICE warnings using e.g. <?php $former = error_reporting(E_ALL ^ E_NOTICE); // or $former = error_reporting(0); Include this at the start of your script before instantiating and running mPDF. It is a good practice to return the former error_reporting after. <?php error_reporting($former);

Add following at top of mpdf.php

error_reporting(0); 

This will resolved the issue.

Getting Undefined index Undefined index: T for some exports · Issue , I've notice that if I type 80 chars 'a' it broke MPDF with the same error than the previous one. If I type 79 it's ok, but it's not depend of the string  This includes checking for ob_get_contents()- a PHP function to check if there is any output in theobject-buffer. If you use object_buffering in the process of preparing the text for mPDF, this will falsely trigger the error message. If this is the case, add the following to your script to prevent it: <?php$mpdf=new\Mpdf\Mpdf(['debug'=>true,'allow_output_buffering'=>true]);

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 :)

undefined index in parsing tables · Issue #800 · mpdf/mpdf · GitHub, Hi guys, we are generating pdf with user input and we found error in combination css table.technical { width: 100%; border-collapse: collapse; }  A non well formed numeric value encountered in Mpdf.php on PHP 7.4.1 and mPDF 8.0 bug/fix notices-warnings research needed #1161 opened Jan 30, 2020 by anjanesh 6

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);
    }

Undefined index: inherit when using Bootstrap 4 and TD · Issue , I found this bug / would like to have this new functionality When using with a bootstrap 4, I get the following error: Notice: Undefined index: inherit in C:\xampp\​htdocs\engage_web\vendor\mpdf\mpdf\src\Tag\Td.php on line 20. When using them, you might encounter an error called “ Notice: Undefined Index ”. This error means that within your code, there is a variable or constant that has no value assigned to it. But you may be trying to use the values obtained through the user form in your PHP code. The error can be avoided by using the isset () function.

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.

Undefined index: current (BlockTag.php:316) · Issue #1122 · mpdf , I found this bug / would like to have this new functionality. Code run into an error when HTML longer than A4 format error stack below. ERROR -2012-11-10 04: 45: 50--> Severity: Notice--> Undefined index: BODY C: Añadir lo siguiente en la parte superior de mpdf.php. error_reporting (0);

Undefined index: data in ImageWriter.php line 96 · Issue #1066 , I found this bug when first using mpdf. The case is when i am rendering pdf with looping, the second loop always return image error : Undefined  Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question.Provide details and share your research! But avoid …. Asking for help, clarification, or responding to other answers.

Notice: Undefined index: miw in /var/www/html/vendor/mpdf/mpdf/src , I found this bug / would like to have this new functionality Notice: Undefined index​: miw in /var/www/html/vendor/mpdf/mpdf/src/Mpdf.php on line  Hey, today I will show you integrating mPDF into CodeIgniter Application. mPDF is a PHP Class, by using this we can easily generate PDF files from HTML Templates.So styling PDF files as easy styling your HTML template as you wish. Here is the updated post on CodeIgniter 3 – Using mPDF with CodeIgniter 3 Following […]

Undefined index: dom in Mpdf.php · Issue #557 · mpdf/mpdf · GitHub, I found this bug after upgrading to mPDF 7. mPDF Version: 7.0.1 PHP Version: 7.1.10 This is the error I am recieving: Notice: Undefined index:  Warning mysqli fetch array expects parameter 1 to be mysqli result, boolean given in:Fixed - Duration: 3:08. 360 Degree Tutorials 48,001 views

Comments
  • FWIW, I had a similar when adding styles to mpdf.css. For me it was that I was trying to add a border: 1mm solid #333 to a tr element (tr, td, th) and that was throwing an error. I didn't find a sufficient validator for CSS to use, but be aware that you CSS must be as well formatted as your HTML.