Question

I am using HTML2PDF converter in PHP to generate PDF.

My html seems to be big so that it could not fit in single page.

I am getting following error when I tried to generate pdf..

'the contents of a TD tag does not fit on a single page'

could not find proper solution yet. Any idea please.

This is my code at end to generate pdf.

require_once("../html2pdf_new/html2pdf.class.php");

try
{
    $html2pdf = new HTML2PDF('P','A4','fr');
    $html2pdf->pdf->SetDisplayMode('fullpage');
    $html2pdf->WriteHTML($content);
    $html2pdf->Output('exemple.pdf');
}

catch(HTML2PDF_exception $e) {
    echo $e;
    exit;
}

$content contains all html.

No correct solution

OTHER TIPS

You can set setTestTdInOnePage as false to overcome this error.

 $html2pdf = new HTML2PDF('P', 'A4', 'en');

 $html2pdf->setTestTdInOnePage(false);

If this problem still exists: I fixed it with the method

HTML2PDF::setTestTdInOnePage(false)

This setting of value works. In the html2pdf main class file we have a method setTestTdInOnePage which does the rendering of td within a single page if set to true. As it is always true we have this exception thrown as our td data exceeds more than one page. So to avoid it we can set it to false to pass the check.

if we have nested tables, it breaks for multiple pages.

Try to avoid nested tables.

It works.

found at Forum

Find this 'throw new HTML2PDF_exception(7);' in html2pdf.class.php and disable it. Like this:

   if ($this->_testTdInOnepage && $this->_subHtml->pdf->getPage()>1) {
       //throw new HTML2PDF_exception(7);
   }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top