Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML2PDF - add more than one page

Tags:

php

pdf

html2pdf

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.

like image 200
Shri Avatar asked Mar 03 '14 11:03

Shri


2 Answers

You can set setTestTdInOnePage as false to overcome this error.

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

 $html2pdf->setTestTdInOnePage(false);
like image 99
mebishwak090 Avatar answered Nov 12 '22 06:11

mebishwak090


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.

like image 24
Musterknabe Avatar answered Nov 12 '22 05:11

Musterknabe