mpdf addPage创建空白页面

时间:2015-02-26 11:58:19

标签: php html css mpdf

当我尝试在for循环中使用$mpdf->addPage()时,不是创建包含内容的新页面而是创建空白页面。我希望在达到某个条件后中断页面,然后在创建新页面后添加内容。这是代码如何流动的粗略概念..

$form = '<html head informatio here >';
          $mpdf->WriteHTML($form);

$form .= '<html body content which is essentiall a nested table >'
          within this section i have a for loop
         for ( $i=0; $i < $rows; $i++ ): 
          $mpdf->WriteHTML($form);  
          at certain points I would do a 
          $mpdf->AddPage();
          endfor; 

$form .= '<html footer information >'

$mpdf->WriteHTML($form);    

结果是所有内容都放在pdf的最后一页上,而我有大约6或7个空白页面。任何帮助将不胜感激..

2 个答案:

答案 0 :(得分:1)

$form = '<html head informatio here>';
          $mpdf->WriteHTML($form);
$form .= '<html body content which is essentiall a nested table >';

          //within this section i have a for loop//

         for ( $i=0; $i < $rows; $i++ ): 
          $mpdf->WriteHTML($form); 

         // at certain points I would do a //

          //$mpdf->AddPage();

           $form .= '<div style="page-break-after:always"></div>';

           $mpdf->WriteHTML( $form);

          endfor; 

$form .= '<html footer information >';


$mpdf->WriteHTML($form);

答案 1 :(得分:0)

请参阅以下mpdf命令。我认为您需要在代码中手动添加分页符。

http://mpdf1.com/manual/index.php?tid=108