Invalid page number in setPage () function: 0

My code for tcpdf

$file_to_show_test_details = 'pdf_view_test_details.tpl'; $test_details= $smarty->fetch($file_to_show_test_details); // Set some content to print $html = <<<EOD $test_details EOD; // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, 'XYZ',$pdf->writeHTML($html, true, false, true, false, '')); 

The writeHTML function does not work, so the error "Invalid page number in setPage () function: 0" appears in the browser. Can someone help me solve this problem?

+4
source share
2 answers

Have you tried using addPage ()?

 //$pdf = new PDF(); $pdf->AddPage(); 
+8
source

In your case, I would recommend skipping the call to $pdf->SetHeaderData and just format the html as you need it to display, and call $pdf->writeHTML correct layout. Keep in mind that you can also use the built-in css in your html and you will have to play for a while until you get what you want, since tcpdf cannot render html as good as the browser, but in the end you will succeed to do it. Html Tables - Your Friend Here

0
source

All Articles