Php 使用html2pdf创建多个pdf文件
我对html2pdf非常陌生,因此一直发现很难在一个循环中创建多个发票:Php 使用html2pdf创建多个pdf文件,php,pdf,while-loop,tcpdf,html2pdf,Php,Pdf,While Loop,Tcpdf,Html2pdf,我对html2pdf非常陌生,因此一直发现很难在一个循环中创建多个发票: require_once(dirname(__FILE__).'/html2pdf/html2pdf.class.php'); while ( $MyRows = mysql_fetch_array($MyQuery) ) { include(dirname(__FILE__).'mypdf.php'); $content = ob_get_clean();
require_once(dirname(__FILE__).'/html2pdf/html2pdf.class.php');
while ( $MyRows = mysql_fetch_array($MyQuery) ) {
include(dirname(__FILE__).'mypdf.php');
$content = ob_get_clean();
try
{
$html2pdf = new HTML2PDF('P', 'A4', 'en');
$html2pdf->pdf->SetDisplayMode('fitpage');
$html2pdf->writeHTML($content, isset($_GET['vuehtml']));
$Filename = "INV".$mem_id.".pdf";
$html2pdf->Output($Filename, 'F');
}
catch(HTML2PDF_exception $e) {
echo $e;
exit;
}
}
但实际情况是,根据我的设计,脚本仅为第一条记录生成一个pdf,然后有时会显示错误,如:
File : html2pdf\_class\parsingHtml.class.php
Line : 117
HTML code invalid, a tag is closed too many times: <td>
HTML : ...> </nobreak> </page>...
文件:html2pdf\\u class\parsingtml.class.php
电话:117
HTML代码无效,标记关闭次数过多:
HTML:…>。。。
有时,它只是重复我的包含设计的内容,因为我创建它的次数是mysql记录在while循环中的次数,但仍然只生成一个pdf。我建议将mypdf.php转换为返回html文件的函数,并在循环中调用该函数,而不是循环
include
。你的方法太复杂了:-)如果你确定文件的质量,你可以尝试添加ob_start()
就在include
行之前,要查看第一个文件是否由mypdf.php
onlyPerfect mate生成,它完成了工作。谢谢你的功能建议,但我认为两者是一样的东西。