使用html2pdf创建多个pdf文件

时间:2015-01-28 01:05:57

标签: 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();
            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>...

有时,它只是回应了我所包含的设计的内容,因为我已经创建了mysql记录在while循环中的次数,但仍然只生成了一个pdf。

0 个答案:

没有答案