phptcpdf

php fixing mini error of TCPDF in line 16498: Undefined index: thread


There is an error which may occur in the creating pdf and i need to face it.

PHP version 5.3

TCPDF version 6.2

if (($dom[$key]['value'] == 'table') AND (!TCPDF_STATIC::empty_string($dom[($dom[$key]['parent'])]['thead'])) ) 
   {
         $dom[($dom[$key]['parent'])]['thead'] = str_replace(' nobr="true"', '', $dom[($dom[$key]['parent'])]['thead']);
        $dom[($dom[$key]['parent'])]['thead'] .= '</tablehead>';
   }

Solution

  • Here is the solution which just need to check the array element.

    if (array_key_exists ('thead',$dom[($dom[$key]['parent'])]))
    {
                        if (($dom[$key]['value'] == 'table') AND (!TCPDF_STATIC::empty_string($dom[($dom[$key]['parent'])]['thead'])) ) {
                        $dom[($dom[$key]['parent'])]['thead'] = str_replace(' nobr="true"', '', $dom[($dom[$key]['parent'])]['thead']);
                        $dom[($dom[$key]['parent'])]['thead'] .= '</tablehead>';
                        }
    }