如何在mpdf中自动添加第二页?

时间:2018-11-22 04:53:08

标签: php html

我想使用mpdf类将html文件转换为pdf。工作正常,但是count > 30页面没有显示,

                  <?php 
              include("connection.php");
              $phase=mysql_query("select * from session where status=1");
              $phasee = mysql_fetch_array($phase);
              $mindate = $phasee['st_date'];
              $maxdate = $phasee['end_date'];

              $query_omr = mysql_query("SELECT * from sit_details a,staff_details b where b.staff_code=a.staff_code and a.val_center=".$_GET['num']);
              $staffrowdet = mysql_fetch_array($query_omr); 

              $query_exam_session = mysql_query("SELECT * from exam_session");
              $row_exam_session = mysql_fetch_array($query_exam_session);
              $randm=rand(100001,999999);
              $text_page='
              <style>
              table {
              width:1000px;
              font-family:Times New Roman, Times; 
              border-collapse: collapse; 
              text-align:justify;
              padding:2px;
              font-size:12px;
              text-transform: uppercase;

              }
              td, th {
              height:30px;
              text-transform: uppercase;
              padding:2px;
              }
              </style>
              <table id="simple-table" >
              <tr><td  colspan="2">
              <table>
                <tr>
                  <td rowspan="3"><img src="assets/images/logo.gif" width="80px" /></td>
                  <td align="center" style="font-size:20px"><strong>Heading1 </strong></td>
                </tr>
                <tr>
                  <td align="center" style="font-size:16px"><strong>Heading2 - '. $row_exam_session['session'].'  </strong> </td>
                </tr>
                <tr>
                  <td align="center" style="font-size:14px"><strong>DETAIL</strong></td>
                </tr>                  
              </table>
              </td></tr>
              <tr><td  colspan="2">

              <table id="dynamic-table" class="table table-striped table-bordered table-hover" width="900" align="left">
              <tr>
                <th colspan="6" style="font-size:14px" align="left">PERIOD  : FROM  <u>'.$mindate .' </u> TO  <u>'.$maxdate.' </u> </th>     
              </tr>

              <div style="width:50px;height:50px;border:1px solid #000;"></div>




              </table>
              </td></tr>






              <tr>
              <td>
              <strong><caption> Form Details</caption> </strong>

              <table id="dynamic-table" class="table table-striped table-bordered table-hover"  border="1" style="page-break-inside: avoid"> <tr bgcolor="#CCCCCC" >
              <th align="center" width="50px"><label class="control-label bolder blue">Sl.No </label></th>
              <th align="center" width="100px"><label class="control-label bolder blue">Staff ID </label></th>
              <th align="left" width="100px"><label class="control-label bolder blue">&nbsp;Staff Name</label></th>
              <th align="left" width="100px"><label class="control-label bolder blue">&nbsp;Designation </label></th>



              </tr>';
              $c1=0;
              while($row_dummy = mysql_fetch_array($query_omr)) {


              $text_page=$text_page.'
              <tr>
              <td align="center"><h3>'. $c1 .'</h3></td>
              <td align="center"><h3>'. $row_dummy['staff_code'].'</h3></td>
              <td align="left"><h3>'. $row_dummy['staff_name'].'</h3></td>
              <td align="left"><h3>'. $row_dummy['staff_designation'].'</h3></td>

              </tr>';
              $c1++;
              }





              $text_page=$text_page.'
              <tr>
              <table >


              </tr> 
              </table>
              </table>

              </td>
              </tr>

              <table  id="dynamic-table" class="table table-striped table-bordered table-hover"  border="1" width="800" >
              <tbody>
                <tr>
                  <th align="center"  width="300px" ></th> <br/>
                  <th align="center" width="150px">Post Held</th>
                  <th align="center" width="250px">Name</th>
                   <th align="center" width="50px">Signature</th>

                </tr>

                <tr>
                  <td> </td>
                  <td align="center" height="70"><strong> <br/>  Officer /  <br/>  Coordinator  </strong> </td>
                  <td height="70"></td>

                </tr>
              <tbody> 



              <td align="right" width="300px" valign="bottom" rowspan="2"  > </td>
              </table>




              </table>
              <table>
              <tr><td align="left"><h4>'.$randm.'</h4></td><td align="right"><h4>'.date('d-m-Y H:i:s').'</h4></td></tr>
              </table>
              ';

              //echo $text_page;
              //exit;

              ob_end_clean();
              ini_set('memory_limit', '500000M');

              include("MPDF57/mpdf.php");
              //$mpdf = new mPDF('c', 'A4-L','0', '0', '10', '10','10', '10'); 
              $mpdf = new mPDF(
                  '',    // mode - default ''
                  'A4',    // format - A4, for example, default ''
                  0,     // font size - default 0
                  '',    // default font family
                  10,    // margin_left
                  10,    // margin right
                  5,    // margin top
                  0,    // margin bottom
                  5,     // margin header
                  5,     // margin footer
                  'P'    // L - landscape, P - portrait
              );
              $mpdf->autoPageBreak = true;
              $mpdf->AddPage();
              $fname=$_GET['num'].".pdf";
              $mpdf->SetWatermarkImage('assets/images/logo.jpg');
              $mpdf->setFooter('{PAGENO}');
              $mpdf->showWatermarkImage = true;
              $mpdf->WriteHTML($text_page);
              $mpdf->Output($fname, 'D'); 
              exit;
              ?>

已下载pdf,但如果count<30页没有响应,则rowcount>30。如何解决这个错误。我找不到解决方案。请提出其他符合我要求的mpdf示例程序。

0 个答案:

没有答案