html2pdf
html2pdf copied to clipboard
Php 7.4 with spipu/html2pdf 5.2 ; count(): Parameter must be an array or an object that implements Countable
Hello !
I'm a junior dev and i'm struggling with an error that i saw as an issue in this Github and tried to fix it on my project ;
A PHP Error was encountered
Severity: Warning
Message: count(): Parameter must be an array or an object that implements Countable
Filename: src/Html2Pdf.php
Line Number: 5150 , 5152, 5153
I tried all that was on the issues #577 #504 #420 and #407 ....
Can you help me to figure out how and where to fix that ?
Thank you for your work !
Hi,
it seems that the error occurs when the table is not good (not the same number of columns on each row) or empty. And i did not put any security on it...
can you provide a little HTML example that cause this pb ?
thanks
Hi !
Yeah of course i have this before my page tag;
</div>object(Spipu\Html2Pdf\Exception\ImageException)#319 (8) {
["image":protected]=>
string(0) ""
["message":protected]=>
string(38) "Unable to get the size of the image []"
["string":"Exception":private]=>
string(0) ""
["code":protected]=>
int(2)
["file":protected]=>
string(86) "/var/www/html/intranet/logiciel-codeigniter-dev/vendor/spipu/html2pdf/src/Html2Pdf.php"
["line":protected]=>
int(1519)
["trace":"Exception":private]=>
array(23) {
[0]=>
array(6) {
["file"]=>
string(86) "/var/www/html/intranet/logiciel-codeigniter-dev/vendor/spipu/html2pdf/src/Html2Pdf.php"
["line"]=>
int(5769)
["function"]=>
string(10) "_drawImage"
["class"]=>
string(23) "Spipu\Html2Pdf\Html2Pdf"
["type"]=>
string(2) "->"
["args"]=>
array(2) {
[0]=>
string(0) ""
[1]=>
bool(false)
}
}
[1]=>
array(6) {
["file"]=>
string(86) "/var/www/html/intranet/logiciel-codeigniter-dev/vendor/spipu/html2pdf/src/Html2Pdf.php"
["line"]=>
int(1439)
["function"]=>
string(13) "_tag_open_IMG"
["class"]=>
string(23) "Spipu\Html2Pdf\Html2Pdf"
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
array(4) {
["style"]=>
array(1) {
["width"]=>
string(3) "68%"
}
["alt"]=>
string(0) ""
["src"]=>
string(0) ""
["num"]=>
int(14)
}
}
}
[2]=>
array(6) {
["file"]=>
string(86) "/var/www/html/intranet/logiciel-codeigniter-dev/vendor/spipu/html2pdf/src/Html2Pdf.php"
["line"]=>
int(1407)
["function"]=>
string(14) "_executeAction"
["class"]=>
string(23) "Spipu\Html2Pdf\Html2Pdf"
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
object(Spipu\Html2Pdf\Parsing\Node)#838 (5) {
["name":"Spipu\Html2Pdf\Parsing\Node":private]=>
string(3) "img"
["params":"Spipu\Html2Pdf\Parsing\Node":private]=>
array(4) {
["style"]=>
array(1) {
["width"]=>
string(3) "68%"
}
["alt"]=>
string(0) ""
["src"]=>
string(0) ""
["num"]=>
int(14)
}
["close":"Spipu\Html2Pdf\Parsing\Node":private]=>
bool(false)
["autoClose":"Spipu\Html2Pdf\Parsing\Node":private]=>
bool(true)
["line":"Spipu\Html2Pdf\Parsing\Node":private]=>
int(177)
}
}
}
[3]=>
array(6) {
["file"]=>
string(86) "/var/www/html/intranet/logiciel-codeigniter-dev/vendor/spipu/html2pdf/src/Html2Pdf.php"
["line"]=>
int(5589)
["function"]=>
string(13) "_makeHTMLcode"
["class"]=>
string(23) "Spipu\Html2Pdf\Html2Pdf"
["type"]=>
string(2) "->"
["args"]=>
array(0) {
}
}
[4]=>
array(6) {
["file"]=>
string(86) "/var/www/html/intranet/logiciel-codeigniter-dev/vendor/spipu/html2pdf/src/Html2Pdf.php"
["line"]=>
int(1439)
["function"]=>
string(12) "_tag_open_TD"
["class"]=>
string(23) "Spipu\Html2Pdf\Html2Pdf"
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
array(4) {
["style"]=>
array(4) {
["width"]=>
string(3) "15%"
["vertical-align"]=>
string(6) "middle"
["padding-middle"]=>
string(3) "5px"
["text-align"]=>
string(6) "center"
}
["num"]=>
int(14)
["cellpadding"]=>
string(18) "0.26458333333333mm"
["cellspacing"]=>
string(18) "0.52916666666667mm"
}
}
}
[5]=>
array(6) {
["file"]=>
string(86) "/var/www/html/intranet/logiciel-codeigniter-dev/vendor/spipu/html2pdf/src/Html2Pdf.php"
["line"]=>
int(1393)
["function"]=>
string(14) "_executeAction"
["class"]=>
string(23) "Spipu\Html2Pdf\Html2Pdf"
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
object(Spipu\Html2Pdf\Parsing\Node)#836 (5) {
["name":"Spipu\Html2Pdf\Parsing\Node":private]=>
string(2) "td"
["params":"Spipu\Html2Pdf\Parsing\Node":private]=>
array(2) {
["style"]=>
array(4) {
["width"]=>
string(3) "15%"
["vertical-align"]=>
string(6) "middle"
["padding-middle"]=>
string(3) "5px"
["text-align"]=>
string(6) "center"
}
["num"]=>
int(14)
}
["close":"Spipu\Html2Pdf\Parsing\Node":private]=>
bool(false)
["autoClose":"Spipu\Html2Pdf\Parsing\Node":private]=>
bool(false)
["line":"Spipu\Html2Pdf\Parsing\Node":private]=>
int(176)
}
}
}
[6]=>
array(6) {
["file"]=>
string(86) "/var/www/html/intranet/logiciel-codeigniter-dev/vendor/spipu/html2pdf/src/Html2Pdf.php"
["line"]=>
int(3123)
["function"]=>
string(13) "_makeHTMLcode"
["class"]=>
string(23) "Spipu\Html2Pdf\Html2Pdf"
["type"]=>
string(2) "->"
["args"]=>
array(0) {
}
}
[7]=>
array(6) {
["file"]=>
string(86) "/var/www/html/intranet/logiciel-codeigniter-dev/vendor/spipu/html2pdf/src/Html2Pdf.php"
["line"]=>
int(1439)
["function"]=>
string(13) "_tag_open_DIV"
["class"]=>
string(23) "Spipu\Html2Pdf\Html2Pdf"
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
array(2) {
["style"]=>
array(1) {
["border-top"]=>
string(14) "1px solid #ccc"
}
["num"]=>
int(0)
}
}
}
[8]=>
array(6) {
["file"]=>
string(86) "/var/www/html/intranet/logiciel-codeigniter-dev/vendor/spipu/html2pdf/src/Html2Pdf.php"
["line"]=>
int(1407)
["function"]=>
string(14) "_executeAction"
["class"]=>
string(23) "Spipu\Html2Pdf\Html2Pdf"
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
object(Spipu\Html2Pdf\Parsing\Node)#824 (5) {
["name":"Spipu\Html2Pdf\Parsing\Node":private]=>
string(3) "div"
["params":"Spipu\Html2Pdf\Parsing\Node":private]=>
array(2) {
["style"]=>
array(1) {
["border-top"]=>
string(14) "1px solid #ccc"
}
["num"]=>
int(0)
}
["close":"Spipu\Html2Pdf\Parsing\Node":private]=>
bool(false)
["autoClose":"Spipu\Html2Pdf\Parsing\Node":private]=>
bool(false)
["line":"Spipu\Html2Pdf\Parsing\Node":private]=>
int(170)
}
}
}
[9]=>
array(6) {
["file"]=>
string(86) "/var/www/html/intranet/logiciel-codeigniter-dev/vendor/spipu/html2pdf/src/Html2Pdf.php"
["line"]=>
int(2971)
["function"]=>
string(13) "_makeHTMLcode"
["class"]=>
string(23) "Spipu\Html2Pdf\Html2Pdf"
["type"]=>
string(2) "->"
["args"]=>
array(0) {
}
}
[10]=>
array(6) {
["file"]=>
string(86) "/var/www/html/intranet/logiciel-codeigniter-dev/vendor/spipu/html2pdf/src/Html2Pdf.php"
["line"]=>
int(1439)
["function"]=>
string(25) "_tag_open_PAGE_FOOTER_SUB"
["class"]=>
string(23) "Spipu\Html2Pdf\Html2Pdf"
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
array(2) {
["style"]=>
array(0) {
}
["num"]=>
int(0)
}
}
}
[11]=>
array(6) {
["file"]=>
string(86) "/var/www/html/intranet/logiciel-codeigniter-dev/vendor/spipu/html2pdf/src/Html2Pdf.php"
["line"]=>
int(1407)
["function"]=>
string(14) "_executeAction"
["class"]=>
string(23) "Spipu\Html2Pdf\Html2Pdf"
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
object(Spipu\Html2Pdf\Parsing\Node)#822 (5) {
["name":"Spipu\Html2Pdf\Parsing\Node":private]=>
string(15) "page_footer_sub"
["params":"Spipu\Html2Pdf\Parsing\Node":private]=>
array(2) {
["style"]=>
array(0) {
}
["num"]=>
int(0)
}
["close":"Spipu\Html2Pdf\Parsing\Node":private]=>
bool(false)
["autoClose":"Spipu\Html2Pdf\Parsing\Node":private]=>
bool(false)
["line":"Spipu\Html2Pdf\Parsing\Node":private]=>
int(169)
}
}
}
[12]=>
array(6) {
["file"]=>
string(86) "/var/www/html/intranet/logiciel-codeigniter-dev/vendor/spipu/html2pdf/src/Html2Pdf.php"
["line"]=>
int(988)
["function"]=>
string(13) "_makeHTMLcode"
["class"]=>
string(23) "Spipu\Html2Pdf\Html2Pdf"
["type"]=>
string(2) "->"
["args"]=>
array(0) {
}
}
[13]=>
array(6) {
["file"]=>
string(86) "/var/www/html/intranet/logiciel-codeigniter-dev/vendor/spipu/html2pdf/src/Html2Pdf.php"
["line"]=>
int(2844)
["function"]=>
string(14) "_setPageFooter"
["class"]=>
string(23) "Spipu\Html2Pdf\Html2Pdf"
["type"]=>
string(2) "->"
["args"]=>
array(0) {
}
}
[14]=>
array(6) {
["file"]=>
string(86) "/var…
<page format="A4" backtop="0mm" backbottom="00mm" backleft="0mm" backright="0mm" orientation="portrait" backimg="/var/www/html/images/icon-desc/bg-label.jpg" backimgy="bottom" backimgx="left" backimgw="50%">
And i call Html2Pdf with
$html2pdfprivate = new Html2Pdf('P', $format, 'fr');
$html2pdfprivate->pdf->SetDisplayMode('fullpage');
$html2pdfprivate->writeHTML($contentprivate, false);
$html2pdfprivate->output($pathFileBien . $file, 'F');