【发布时间】:2016-06-02 06:44:18
【问题描述】:
我想在其中循环我的 PDF 内容,目前我正在使用 DOMPDF 来创建 PDF。在循环 PDF 内容时,我没有任何 pdf 内容。如果我删除循环,我会得到 pdf。实际上,我想要一个包含 5 页的 PDF。
谁能帮帮我?提前致谢。
<?php
include('config/config.php');
require_once('dompdf_config.inc.php');
error_reporting(0);
for ($i = 0; $i <= 5; $i++) {
//here is my content to loop
$pdf_content = '<body>
<table width="450" border="0" cellpadding="5" class="table_data">
<tr>
<td class="left_col">3. Chassis No</td>
<td><b>: ' . $chass_no . ' </b></td>
</tr>
<tr>
<td class="left_col">4. Engine No. </td>
<td> <b> : ' . $engine_id . ' </b></td>
</tr>
</table>
</body>
';
//create pdf function
function createPDF($pdf_userid, $pdf_content, $pdf_For, $filename)
{
$path = 'UsersActivityReports/';
$dompdf = new DOMPDF();
$dompdf->load_html($pdf_content);
$dompdf->render();
$output = $dompdf->output();
file_put_contents($path . $filename, $output);
file_get_contents('output1.php');
return $filename;
}
$name = date("d-m-y") . rand() . '.pdf';
$reportPDF = createPDF(12, $pdf_content, 'activity_Report', $name);
}
//loop ends here
?>
<iframe class="prv_pdf" src="/UsersActivityReports/<?php echo $name ?>#zoom=50" height="300px" width="440px">
【问题讨论】:
-
找到任何东西 dhh