MPDF生成多个页面而不是一个页面

时间:2015-01-13 09:21:11

标签: php mysql mpdf

我正在使用MPDF 5.4,当我尝试使用PDF时,它会在多个页面而不是一个页面中显示记录。例如,如果我有50条记录,它只需要一页,但PDF生成23页。当我选择特定类别并拍摄PDF时会发生这种情况。当我尝试回显内容变量时,它会显示正确对齐的记录。

 <?php 
    include("../MPDF54/mpdf.php");
    $mpdf   =   new mPDF('utf-8','A4', 0, '', 0, 0, 12, 12, 0, 0, 'L');
    //$mpdf->myvariable = file_get_contents($image_url);
    ?>
    <?php 
    $content_html   =   '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Item Report</title>
    <style type="text/css">
    body{margin:0px; padding:0px; text-align: justify; font-family: Arial, Helvetica, sans-serif; font-size:12px; line-height:20px; color:#000}
    </style>
    </head>
    <body>



    <div style="float:left; width:100%; padding:0%; margin-top:0px;">





    <table width="100%" border="0" cellspacing="0" cellpadding="10">
                                    <thead>
                                        <tr height="33" bgcolor="#666" style="color:#FFFFFF" align="left">
                                            <th align="left" style="color:#FFFFFF">Description</th>
                                            <th align="left" style="color:#FFFFFF">Part No.</th>
                                  <th align="left" style="color:#FFFFFF">Location Code</th>
                                  <th align="left" style="color:#FFFFFF">Open Qty</th>
                                  <th align="left" style="color:#FFFFFF">Total IN</th>
                                  <th align="left" style="color:#FFFFFF">Total OUT</th>
                                            <th align="left" style="color:#FFFFFF">Bal Qty</th>
                                        </tr>
                                    </thead>
                                    <tbody>';


                                    $slno=0;
                                    $category_name  =   "";
                                    foreach($array_item_list as $itemlist){
                            $slno++;
                            if($slno%2)
                                        $row_style  =   'style="background:#fff;"';
                                    else
                                        $row_style  =   'style="background:#e9e9e9;"';

                                    if($itemlist['category_status']=="A"){
                                    if($item_category){
                               if($item_category==$itemlist['category_id']){
                               $item_count_arr  =   $ObjItem->getitemdetails('','',$search_text,'A',$itemlist['category_id'],$item_type);
                               $item_count  =   $ObjItem->_num_rows;
                               }else{
                                  $item_count    =  0;
                               }
                            }else{
                            $item_count_arr =   $ObjItem->getitemdetails('','',$search_text,'A',$itemlist['category_id'],$item_type);
                                    $item_count =   $ObjItem->_num_rows;
                            }

                                    if($item_count>=1){
                                    if ($itemlist['category_name'] != $category_name) {
                                        $category_name = $itemlist['category_name'];
                                        //print "<h1>".$category_name."</h1>\n";

                                    $content_html .= '<tr>                           
                                        <td style="font-weight:bold;background:#ddd;" colspan="8">'. $category_name .'</td>
                                    </tr>';
                                     }
                                    if($itemlist['item_id']!=""){
                                    if($itemlist['item_part_no']) $item_part_no = $itemlist['item_part_no']; else $item_part_no = '--';

                                    $location_id    =   $itemlist['item_location_id'];
                                    $location_arr   =   $ObjLocation->getLocationDetails($location_id,'','','A','');
                                    if($location_arr){
                                        $location_name          =   $location_arr[0]['location_name'];
                                        $location_description   =   $location_arr[0]['location_description'];
                                    }

                                    $qty_arr                        =   $ObjStockReport->getTotalQty($itemlist['item_id'],'IN');
        if($qty_arr[0]['total_qty']) $in_qty = $qty_arr[0]['total_qty']; else $in_qty = '0';

                                    $qty_arr                        =   $ObjStockReport->getTotalQty($itemlist['item_id'],'OUT');
        if($qty_arr[0]['total_qty']) $out_qty = $qty_arr[0]['total_qty']; else $out_qty = '0';

                            if($itemlist['item_open_qty'])
                               $item_open_qty = $itemlist['item_open_qty'];
                            else
                               $item_open_qty = '0';

                            if($itemlist['item_balance_qty'])
                               $item_balance_qty = $itemlist['item_balance_qty'];
                            else
                               $item_balance_qty = '0';

                                    $content_html .= '<tr '.$row_style.'>   
                                            <td>'. $itemlist['item_name'] .'</td>
                                            <td>'. $item_part_no .'</td>
                                  <td>'. $location_description .'</td>
                                  <td>'. $item_open_qty .'</td>
                                  <td>'. $in_qty .'</td>
                                  <td>'. $out_qty .'</td>
                                  <td>'. $item_balance_qty .'</td>
                                        </tr>';
                                         }

                                    }   }    }                                  


                                    $content_html .= '</tbody>
                                </table>';


    $content_html .= '</div>

    </body>
    </html>';
    $mpdf->SetHTMLHeader('<div style="float:left; width:96%; padding:0 2%; padding-top:3px; height:42px; background:#212121; ">
    <div style="float:left; width:50%; margin-top:5px;"><img src="../assets/img/login_icon2.png"/></div>
    <div style="float:right; width:49%; margin-right:1%; text-align:right; margin-top:12px; color:#FFFFFF; text-transform:uppercase; font-size:20px;">Item Report</div>
    </div>');
    $mpdf->SetHTMLFooter('<div style="width:96%; padding:0 2%; padding-top:3px;  height:42px; background:#bbb; color:#000; ">
    <div style="float:left; width:50%; margin-top:5px;text-align:left; margin-top:12px;">'. date('d-m-Y H:i a') .'</div>
    <div style="float:right; width:49%; margin-right:1%; text-align:right; margin-top:12px; color:#000; font-size:12px;">Arabinfotech L.L.C.</div>
    </div>');
    $mpdf->WriteHTML($content_html);
    $mpdf->Output();
    ?>

0 个答案:

没有答案