html2pdf
html2pdf copied to clipboard
Fatal error with empty textarea
I am using html2pdf v5.2.1. I encounter the following error with an empty textarea:
$oHtmlToPdf = new Html2Pdf();
$oHtmlToPdf->writeHTML('<h1>Foo</h1><p><textarea></textarea></p>');
Notice: Undefined offset: 0 in /sources/vagrant/vendor/spipu/html2pdf/src/Html2Pdf.php on line 6007
Fatal error: Call to a member function getParam() on null in /sources/vagrant/vendor/spipu/html2pdf/src/Html2Pdf.php on line 6007
This appears to be caused by the empty textarea. When I put a space inside the textarea:
<textarea> </textarea>
, the error does not occur.
Is this a known problem?
Best Regards,
Arno
Thanks for this report it is a new issue
Hello!
This bug is still active at current version 5.2.8. I found how to fix this issue. Add check for variable $level. At line 6026 for version 5.2.8. File vendor/spipu/html2pdf/src/Html2Pdf.php.
Current code
$prop['value'] = $level[0]->getParam('txt', '');
Fixed code
if($level[0]){ $prop['value'] = $level[0]->getParam('txt', ''); }
May you add this code to fix issue?