简体   繁体   English

最大表记录期间的 codeigniter dompdf 分页问题

[英]codeigniter dompdf page break issue during maximum table records

For limited table records pdf looking good.对于有限的表格记录 pdf 看起来不错。

All table records are looking good in "echo $html", but after pdf creation page break is not working when table records are maximum.所有表格记录在“echo $html”中看起来都不错,但在创建 pdf 后,当表格记录最大时,分页符不起作用。 It creates first 4-5 pages empty during maximum records.它在最大记录期间创建前 4-5 页为空。

codeigniter dompdf page break issue during maximum table records:最大表记录期间的 codeigniter dompdf 分页问题:

My code snippet:我的代码片段:

//controller code //控制器代码

function pdf_create($html, $filename='', $stream=TRUE) 
    {
        require_once("dompdf/dompdf_config.inc.php");

        $dompdf = new DOMPDF();
        $dompdf->load_html($html);
        $dompdf->render();
        if ($stream) {
            $dompdf->stream($filename.".pdf");
        } else {
            return $dompdf->output();
        }
    }

//view file code //查看文件代码

    ......
       ......  
        <tr>
                <td>
              <table width="100%" border="0" style="border:solid 1px #BFBFBF; page-break-inside: auto;" cellspacing="0" cellpadding="10">
       <tr bgcolor="#BFBFBF">
        <td><p style="font-size:14px; margin:0px;">Product Name</p></td>
        <td><p style="font-size:14px; margin:0px;">Product Quantity</p></td>
        <td><p style="font-size:14px; margin:0px;">Product Price</p></td>
        <td><p style="font-size:14px; margin:0px;">Total Price</p></td>
      </tr>
      <?php
$product_title = $product_details['product_titles'];
$prod_quantity = $product_details['product_qty'];
$price = $product_details['product_price'];
$total_price = $product_details['product_cal_price'];
$i = 1;
$j = 0;
$productwisetotal = 0;
foreach ($product_title as $value) { $productwisetotal += $value; ?>      
          <tr style="font-size:12px;" valign="top">
              <td style="border-right:solid 1px #BFBFBF"><?php echo $i.'. '.$value; ?></td>
              <td style="border-right:solid 1px #BFBFBF"><?php echo $prod_quantity[$j]; ?></td>
              <td style="border-right:solid 1px #BFBFBF"></td>
              <td style="border-right:solid 1px #BFBFBF"></td>
          </tr>
<?php    $i++;
         $j++;
       } ?>      
    </table>  

                </td>    
                </tr>
        .....
        .....

please give me idea how can i add page break in pdf when table contains maximum records??请告诉我当表格包含最大记录时如何在 pdf 中添加分页符?

Add the page-break-inside: auto for the parent table like bellow为父表添加page-break-inside: auto如下所示

<table style="page-break-inside: auto">
<tr>
<td>

<table width="100%" border="0" style="border:solid 1px #BFBFBF;" cellspacing="0" cellpadding="10">
       <tr bgcolor="#BFBFBF">
-------
</table>
        $mpdf = new \Mpdf\Mpdf();
        $html = $this->load->view('client_tid_pdf', $data,true);
        $mpdf->autoPageBreak = true;
        $mpdf->setAutoTopMargin='stretch';
        $mpdf->setAutoBottomMargin = 'stretch';
        $mpdf->WriteHTML($html);
        $mpdf->Output(); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM