4

我在我的网络应用程序中使用 mPDF。

我必须在 Mpdf 的帮助下创建发票文档。因此,具有大量行的 html 表(即:如果存在单页)会出现此错误:

警告:在第 11008 行的 MPDF56/mpdf.php 中为 foreach() 提供的参数无效

我正在使用以下代码生成pdf:

require_once(MPDF_PATH);
$mpdf=new mPDF('c','A4','0','',2,2,2,2,1,1);
$stylesheet = file_get_contents(dirname(__FILE__).'/invoice_print.css');
$mpdf->WriteHTML($stylesheet,1);
$html .="";
$mpdf->WriteHTML($html);
$mpdf->Output("$fileName",'D'); 

我在 Mpdf 的构造函数中尝试了带/不带参数。我发现 mpdf 与前 4 个参数一起工作没有任何问题......

$mpdf=new mPDF('c','A4','0','')

但是当我添加“边距”(即:5-8)参数时,会抛出上述错误。

有没有人解决这个问题???

我尝试过使用 mPDF 5.3 和 5.6

4

3 回答 3

5

是的...我从 MPDF 论坛得到了修复...

这是链接:http ://www.mpdf1.com/mpdf/forum/comments.php?DiscussionID=1109&page=1#Item_0

解决方案:只需将“ TableHeaderFooter ”函数的第一行替换为:

if(($horf=='H' || $horf=='F') && !empty($content)) {

至:

if(($horf=='H' || $horf=='F') && !empty($content) && !empty($content[0]) ) {

希望这对其他人有帮助...

于 2013-05-21T17:00:09.250 回答
2

我目前也在使用 mPDF。我发现你最好像这样设置边距:

$style = '<style>
@page *{
    margin-top: 2.54cm;
    margin-bottom: 2.54cm;
    margin-left: 3.175cm;
    margin-right: 3.175cm;
}
</style>';

$mpdf->WriteHTML($style); //This writes the margin styles
$mpdf->WriteHTML($output); //This writes the html output
于 2013-05-21T16:49:34.190 回答
0

出现此错误是因为您没有在 HTML 内的表格中设置<thead>
<tbody>标签。

于 2019-02-21T11:21:36.323 回答