Wrong page number on setPage() function: 0

依然范特西╮ 提交于 2020-01-13 11:46:10

问题


My code for tcpdf is

$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 function writeHTML is not working, that's why the error 'Wrong page number on setPage() function: 0' appears in the browser. Could anyone please help me to solve this issue?


回答1:


Did you try to use addPage()?

//$pdf = new PDF();

$pdf->AddPage();



回答2:


For your case I would recommend skipping call to $pdf->SetHeaderData and just format the html the way you need pdf to be displayed and call $pdf->writeHTML with correct layout. Mind you that you can also use inline css in your html and you will have to play a while until you get that you want since tcpdf can't render html as good as browser but you will manage to do it eventually. Html tables are your friend here



来源:https://stackoverflow.com/questions/14499685/wrong-page-number-on-setpage-function-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!