我用 PHP 开发了一个软件并用 TCPDF 报告。它运行良好,但是在 MySQL 中导入大量数据后,PHP 无法在浏览器超时之前生成报告。我尝试过使用最新的 firefox 和 Chrome 版本。
这是我的脚本:
<?php
require_once('tcpdf/config/lang/eng.php');
require_once('tcpdf/tcpdf.php');
// create new PDF documentation
include "koneksi.php"; //file conection
$bln=$_POST[BLN]; //for catch month
$thn=$_POST[THN]; //for catch year
$exp=$_POST[EXP]; //for catch expedition name
if(empty($exp))
{
$sql = "SELECT * FROM tb_exp_local where bulan = '$bln' AND tahun = '$thn'";
}
elseif($exp != "")
{
$sql = "SELECT * FROM tb_exp_local where bulan = '$bln' AND tahun = '$thn' AND nama_exp = '$exp'";
}
$hasil = mysql_query($sql);
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set font
$pdf->SetFont('times', '', 11);
// landscape
$pdf->addPage( 'L', 'LETTER' );
//this for convert html to pdf with html function
$html = '
<table border="1" cellspacing="3" cellpadding="4">
<tr><td colspan="9" align="center"><h2>Form Pantauan Expedisi Export</h2></td></tr>
<tr>
<th align="center"><b>Tanggal</b></th>
<th align="center"><b>Nama Expedisi</b></th>
<th align="center"><b>Nama Distributor</b></th>
<th align="center"><b>Kota Tujuan</b></th>
<th align="center"><b>No Faktur</b></th>
<th align="center"><b>Kondisi Armada Pengiriman</b></th>
<th align="center"><b>Ketepatan Jumlah</b></th>
<th align="center"><b>Ketepatan Waktu Kirim</b></th>
<th align="center"><b>Keterangan</b></th>
</tr></table>';
while ($data = mysql_fetch_array($hasil))
{
$html .= '<table border="1"><tr><td align="center">'.$data['tgl'].'</td>
<td align="center">'.$data['nama_exp'].'</td>
<td align="center">'.$data['nama_dist'].'</td>
<td align="center">'.$data['kota_tujuan'].'</td>
<td align="center">'.$data['faktur'].'</td>
<td align="center">'.$data['konarmada'].'</td>
<td align="center">'.$data['tepatjml'].'</td>
<td align="center">'.$data['tepatwaktu'].'</td>
<td align="center">'.$data['ket'].'</td>
</tr></table> ';
}
$pdf->writeHTML($html, true, false, true, false, ''); //for generate
$pdf->Output('FormPantauExpLocalAll', 'I'); // for generate pdf file
?>