PHP - TCPDF不显示页面和表

时间:2013-06-07 00:43:14

标签: php mysql tcpdf

我的语法错误,页面和表格都没有显示。我不确定。谁能帮我? TNX

我甚至在stackoverflow中都是这个脚本。我测试了tcpdf示例,他们正在工作。所以我将示例项目放在一个页面中。我试图运行它。什么都没有显示出来。

请帮忙。

<?php

include('connect.php');
    //require_once('../tcpdf/config/lang/eng.php');
    require_once('../tcpdf/tcpdf.php');
    // create new PDF document
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8',       false);

    // set default font subsetting mode
    $pdf->setFontSubsetting(true);


    $pdf->SetFont('dejavusans', '', 14, '', true);

    // Add a page

    $pdf->AddPage("L");

    $query=mysql_query("SELECT fname,mname,lname FROM emp_tbl");


    $tbl_header = '<table style="width: 638px;" cellspacing="0">';
    $tbl_footer = '</table>';
    $tbl = '';

    $tbl_header = '<table id="gallerytab" width="600" cellspacing="2" cellpadding="1"   border="0">
    <tr>
    <th><font face="Arial, Helvetica, sans-serif">Employee Name</font></th>

    </tr>';

    $tbl_footer = '</table>';
    $tbl = '';

    while($row = mysql_fetch_array($query))
    {
$tbl .= '
<tr>
    <td>'.$row['fname'].''.$row['mname'].''.$row['lname'].'</td>
</tr>
        ';
   }
     // output the HTML content
    $pdf->writeHTML($tbl_header . $tbl . $tbl_footer, true, false, false, false, '');

    ?>

1 个答案:

答案 0 :(得分:2)

你的php文件还没完成。您是如何想要PDF输出的(例如文件,内联浏览器等)?无论哪种方式添加如下内容:

return $pdf->Output('filename.pdf', 'I');
  • 我:内联
  • D:在浏览器中下载
  • F:将文件保存到服务器
  • S:输出为php string

那应该这样做。