当 pdf 文件保存到磁盘时,tcpdf 库不在循环内打印数据

tcpdf library not printing data inside loop when pdf file is saved to disk

下面是我创建 pdf 的代码。当 pdf 保存到磁盘时,循环内的数据不显示在 pdf 中。
当您只在浏览器中显示您的 pdf 或下载它时就可以了。但是当我将 pdf 保存到磁盘时出现问题告诉我如何解决这个问题。
当在 writeHTML() 函数中传递 html 时,这可能是个问题。我的 html 连接有问题吗?

 $html = '
<h1>Castlenet Limited </h1><br>

<div style="line-height:10px;">
<p >8 Eclipse Lane</p><br><br>
<p >Whitby</p><br>
<p >04 234 6336</p><br><br><br>
</div>
<div style="line-height:10px;">
<p>CUST_NAME : '.$metadata['customer']['cust_ref'].'</p><br>
<p>CUST_COMPANY : '.$metadata['customer']['cust_company'].'</p><br>
<p>CUST_EMAIL: '.$metadata['customer']['cust_email'].'</p><br>
<p>CUST_PHONE : '.$metadata['customer']['cust_phone'].'</p><br>
</div>';
$pdf->writeHTML($html, true, false, false, false, '');

foreach ($metadata['websites'] as $data)
{
        $html = '<b>Website :'. $data['web_title'].'      '. $data['web_url'].' </b><br><b>Storage :'. $data['stor_type'].' </b><br><table border="1" style="width:100%"><tr><th style="width:40%;">Date</th><th style="width:20%;">size</th><td>File</td></tr>';

        $pdf->writeHTML($html, true, false, false, false, '');

        foreach ($data['files'] as $file)
        {
            //$html .= '<tr><td><pre>'.print_r($file).'</td></tr>';
            $html = '<tr><td></td>
                            <td>'. $file["size"].'</td>
                            <td>'. $file["path"].'</td>
                        </tr>
                        ';
            $pdf->writeHTML($html, true, false, false, false, '');


        }
        $html = '</table><br><br>';
        $pdf->writeHTML($html, true, false, false, false, '');

  } 


// Print text using writeHTMLCell()
//$pdf->writeHTML($html, true, false, false, false, '');
//$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);   

// ---------------------------------------------------------    
//$pdf->lastPage();
// Close and output PDF document

//This method has several options, check the source code documentation for more information.
$pdf->Output($_SERVER['DOCUMENT_ROOT'].'projects/reports/assets/reports/example_001.pdf', 'F');    

//============================================================+
// END OF FILE
//============================================================+
}

块引用

Got the solution!. For attaching a file you have to put 'E' instead of 'F' in
$this->Output('example.pdf','E'); and u dont have to call again again writeHTML() function just call it once after the loop ends.