tecnickcom / TCPDF

Official clone of PHP library to generate PDF documents and barcodes
https://tcpdf.org
Other
4.18k stars 1.51k forks source link

TOC bug in php 8? #472

Open cstdenis opened 2 years ago

cstdenis commented 2 years ago
Argument #2 ($times) must be greater than or equal to 0 in vendor/tecnickcom/tcpdf/tcpdf.php:21765
Stack trace:
#0 vendor/tecnickcom/tcpdf/tcpdf.php(21765): str_repeat(' ', -3)
#1 extensions/tcpdf/ETcPdf.php(94): TCPDF->addHTMLTOC(1, 'INDEX', Array, true, 'B', Array)

Version : 6.4.4 PHP 8.0.12

Code that invokes the error

            $bookmark_templates[0] = '<table border="0" cellpadding="3" cellspacing="0">
                            <tr>
                                <td width="25mm"></td>
                                <td width="105mm"><span style="font-weight:bold;font-size:12pt;color:black;">#TOC_DESCRIPTION#</span></td>
                                <td width="25mm"><span style="font-family:courier;font-weight:bold;font-size:12pt;color:black;" align="right">#TOC_PAGE_NUMBER#</span></td>
                                <td width="25mm"></td>
                            </tr>
                            </table>';

            $pdf->addHTMLTOC(1, 'INDEX', $bookmark_templates, true, 'B', array(128,0,0));
cstdenis commented 2 years ago

This is triggered when the document has > 999 pages. addTOC() works, but addHTMLTOC() is broken.