MPDF最后显示一个额外的页面

时间:2015-05-06 14:05:50

标签: php pdf mpdf

我使用mpdf从html生成pdf。

这个生成的pdf有一个问题,即显示一页额外的内容。如果内容在第1页结束,则它生成2页,如果内容在第2页结束,则生成3页。

这是我的代码 -

<?php 

include("mpdf/mpdf.php");

$mpdf=new mPDF('fsalbertpro','A4','','' , 0 , 0 , 0 , 0 , 0 , 0);

$html='----'; // this variables contain all css and HTML to be shown in PDF

ob_clean(); // cleaning the buffer before Output()

$mpdf->SetDisplayMode('fullpage');

$mpdf->list_indent_first_level = 0;  // 1 or 0 - whether to indent the first level of a list

$mpdf->WriteHTML($html);

$mpdf->Output();

?>

然后如何删除最后一个空白页。

3 个答案:

答案 0 :(得分:2)

我遇到了同样的问题。有一次,我有一个

style="page-break-after:always" 

导致空白页面。删除后,空页消失了。

答案 1 :(得分:0)

在跟踪我的代码以查找解决方案时,我注意到使用某些类名后出现了空白页!唯一的解决办法就是重命名类!

我有:

<div class="A4 paper" ...>

通过重命名“ paper”类的空白页消失了!

<div class="A4 papir" ...>

课堂内容无变化!

答案 2 :(得分:0)

请验证您内容的正确html标记。

我失踪了

</div>

这导致显示空白页。

相关问题