Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php tcpdf库html呈现太慢_Php_Html_Tcpdf - Fatal编程技术网

Php tcpdf库html呈现太慢

Php tcpdf库html呈现太慢,php,html,tcpdf,Php,Html,Tcpdf,我正在使用tcpdf(版本5.9.161)writeHtml()仅在我的代码中呈现html表。如果表格只用于一个pdf页面,那么它可以正常工作,但是如果表格大到可以容纳60页,那么它将需要100-110秒。php脚本在2-3秒内生成此html php.ini: Max Execution Time 300 sec memory limit 128MB 我的代码是: $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT,

我正在使用tcpdf(版本5.9.161)
writeHtml()
仅在我的代码中呈现html表。如果表格只用于一个pdf页面,那么它可以正常工作,但是如果表格大到可以容纳60页,那么它将需要100-110秒。php脚本在2-3秒内生成此html

php.ini:

Max Execution Time 300 sec
memory limit 128MB
我的代码是:

$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);        
$pdf->setHeaderFont(Array( PDF_FONT_NAME_MAIN, '',PDF_FONT_SIZE_MAIN ));
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);   
$pdf->SetFontSubsetting(false);        
$pdf->SetHeaderData(K_PATH_IMAGES.'alpha.png', PDF_HEADER_LOGO_WIDTH,'BSS Tech', '');        
$pdf->setPrintHeader(true);     
$pdf->SetAutoPageBreak(true, 30);
$pdf->setPrintFooter(true);        
$pdf->AddPage();
$pdf->writeHTML($html, true, false, false, false, '');
ob_clean();
$pdf->Output("report.pdf", 'I'); // finalizing pdf document
和HTML,不使用任何类型的css

此表用于以pdf格式显示至少600条记录

 $html .= ' <div style="text-align: center;"> 
    <table   border="0"  cellpadding="2px" cellspacing="0"><tbody>
    <tr >
    <th align="left" style="width:120px;font-weight:bold" >Organization Name:</th>
    <th align="left">' . $OrgName . '</th>
    <th align="left"  style="width:100px;font-weight:bold">Field :</th>
    <th align="left" >' . $fieldName . '</th>
    </tr>

    <tr >
    <th align="left" style="width:120px;font-weight:bold">Component:</th>
    <th align="left" >' . $type . '</th>
    <th align="left"  style="width:100px;font-weight:bold"></th>
    <th align="left"  >' . '' . '</th></tr>

    </tbody></table></div>';


    $html .= ' <div style="text-align: center;"> 
    <table   border=".5"  cellpadding="2px" cellspacing="0"><tbody>
    <tr >
    <th align="left" BGCOLOR="#DBFEF8" style="width:5%;font-weight:bold" >SI#:</th>
    <th align="left" BGCOLOR="#DBFEF8" style="width:13%;font-weight:bold" >CP Component</th>
    <th align="left"  BGCOLOR="#DBFEF8" style="width:15%;font-weight:bold">Component ID :</th>
    <th align="left" BGCOLOR="#DBFEF8" style="width:10%;font-weight:bold">Circuit No</th>
    <th align="left" BGCOLOR="#DBFEF8"  style="width:12%;font-weight:bold">Location</th>
    <th align="left" BGCOLOR="#DBFEF8" style="width:15%;font-weight:bold">Over All Status</th>
    <th align="left" BGCOLOR="#DBFEF8" style="width:15%;font-weight:bold">Remark</th>
    <th align="left" BGCOLOR="#DBFEF8" style="width:15%;font-weight:bold">Date</th>
    </tr>';

    for ($i=0 ; $i<count($clientID);$i++){
    $html .= '  
    <tr >
    <th align="left"  style="width:5%;">'.($i+1).'</th>
    <th align="left"  style="width:13%;">'.$clientID[$i]['Type'].'</th>
    <th align="left"  style="width:15%;">'.$clientID[$i]['ComponentID'].'</th>
     <th align="left"  style="width:10%;">'.$clientID[$i]['CircuitLabel'].'</th>
    <th align="left"  style="width:12%;">'.$clientID[$i]['Location'].'</th>
    <th align="left"  style="width:15%;">'.$clientID[$i]['OverAllStatus'].'</th>
    <th align="left"  style="width:15%;">'.$clientID[$i]['FieldObservation'].'</th>
    <th align="left"  style="width:15%;">'.$clientID[$i]['SurveyDate'].'</th>
    </tr>';
    }

    $html .= '</tbody></table></div>';       
    }
$html.='
机构名称:
' . $“原名。”
字段:
' . $字段名。”
组成部分:
' . $打字。”
' . '' . '
';
$html.='
西#:
CP组件
组件ID:
电路号
位置
全面地位
评论
日期
';

对于(i元=0 ;$i@PhpFreak应用程序是用tcpdf开发的。如果跳过标题图像怎么办?你必须找出脚本的哪个部分使其速度非常慢。如果增加内存限制怎么办?@Stephan Vierkant尝试删除所有标题内容,但没有任何改进…..唯一变量中有两个表标记。请尝试使用不同的变量。同时尝试使用
$pdf->writeHTMLCell()
,看看它是否会变得更好。您是否尝试过增加内存限制?顺便说一句:渲染正常HTML页面的2-3秒也非常慢。您是如何测量的?