這一直在竊聽我幾個小時。當我嘗試生成PDF時,出現此錯誤: 1)警告:在C:\ xampp \ htdocs \ KPAPMS \ PHP \ lib \ pdftable.php中劃分爲零 2)FPDF錯誤:某些數據已經存在已輸出,無法發送PDF文件錯誤生成pdf - PHP
我只是使用現有的代碼來生成pdf(fpdf)。
這是我的代碼示例
<?php
$sql = "SELECT * from vesservice";
$res = mysql_query($sql);
$hdd= "<table width=100%>
<tr><th width=100><strong>Company</strong></th><th><strong>: Kuching Port Authority</strong></th><th></th>
<th>Date/Time: ".$date."</th></tr>
<tr><th width=100><strong>Title</strong></th><th><strong>: Water Supply for SCN</strong></th><th></th><th></th></tr>
<tr><th colspan=4><hr></th></tr>
<tr>
<th><strong>SCN</strong></th><th>:</th>
<th><strong>Berth Date</strong></th><th>:</th></tr>
<tr>
<th><strong>Debtor Code</strong></th><th>:</th>
<th><strong>Expected Depart Date/Time</strong></th><th>:</th></tr>
<tr>
<th></th><th></th>
<th><strong>Actual Depart Date/Time</strong></th><th>:</th></tr>
<tr><th colspan=4><hr></th></tr>
</table>";
$tables="<table width=100%>
<tr align=center>
<th>Service Reference</th>
<th>Service Code</th>
<th>Water Supply Reference</th>
<th>Water Supply Sequence</th>
<th>Tariff Code</th>
<th>Tariff Description</th>
<th>UOM</th>
<th>Service Date</th>
<th>Requested Time</th>
<th>Volume<br />(Tonne)</th>
<th>Service Date</th>
<th>Started Time</th>
<th>Volume<br />(Tonne)</th>
<th>Service Date</th>
<th>Ended Date</th>
<th>Duration</th></tr>";
while($rs=mysql_fetch_assoc($res))
{
$tables.= "<tr align=center>
<td>".$rs['serv_opt']."</td>
<td>".$rs['dt_code']."</td>
<td>".$rs['scn']."</td>
<td>".$rs['term_code']."</td>
<td>".$rs['serv_cat']."</td>
<td>".$rs['serv_code']."</td>
<td>".$rs['activ_cnt']."</td>
<td>".$rs['serv_date_req']."</td>
<td>".$rs['serv_shift_req']."</td>
<td>".$rs['serv_qty']."</td>
<td>".$rs['serv_ref']."</td>
<td>".$rs['res_serv_date']."</td>
<td>".$rs['res_serv_time']."</td>
<td>".$rs['new_serv_date']."</td>
<td>".$rs['new_serv_time']."</td>
<td>".$rs['new_serv_qty']."</td>
</tr>";
}
$tables.="</table>";
//echo $hdd.'<br />'.$tables;
$p = new PDFTable('L','mm','a4');//set page orientation P/L
$p->SetFont('Times','',10);
$p->headerTable=$hdd;
$p->AddPage();
$p->htmltable($tables);
//ob_end_clean();
$p->output("Water Supply.pdf",'I'); //D=download
當我uncommet的ob_end_clean,它可以生成PDF輸出,但只打印$表,但不打印頭。 請幫助我,哪一部分我做錯了。
這裏是使用DOMPDF生成PDF的教程。 http://advancetechtutorial.blogspot.com/2015/09/pdf-generate-in-codeigniter-using-dompdf.html –