2015-11-06 89 views
1

here is sample imageDOMPDF页面breakes不工作

<!DOCTYPE html> 
<html class="bg-black"> 
<head> 
    <meta charset="UTF-8"> 
    <title><?php if(isset($title)) echo $title.' | '; ?> Sales agent management software (SAMS) </title> 

    <style> 
     body{ 
      font-size: 9px; 
      margin: 20px; 
     } 
     th,td,p,div,table,h3{margin:0;padding:0} 

     @page { margin: 20px; } 

     .header{ 
      border-bottom: 1px solid #dddddd; 
      text-align: center; 
      position: fixed; top: 0; 
     } 
     .footer { position: fixed; bottom: 0px; text-align: center } 
     .pagenum:before { content: counter(page); } 

    </style> 
</head> 

<body> 

<div class="header"> 
    <h2><?php echo get_option('company_name'); ?> Catalog</h2> 
</div> 
<br /><br /> 

<div class="footer">Page: <span class="pagenum"></span>, creation time : <?php echo date('l jS \of F Y h:i:s A') ?>, create by: <?php echo user_full_name(singleDbTableRow(loggedInUserData()['user_id'])); ?></div> 

<br /> 
<div class="box-body"> 

    <?php 
    $usd = get_option('lkr_per_usd', 134); 
    ?> 


    <?php 
    $result = array_chunk($products->result_array(), 3); 

    foreach($result as $products){ ?> 
     <table style="width:100% style="page-break-after:always;" > 

     <tr> 
     <?php 
     foreach($products as $productArray){ 
      $product = (object) $productArray; 
      echo '<td>'; 
     ?> 

     <div style="width: 100%; height: 210px; border: 1px solid #dddddd; margin: 10px; padding: 5px;"> 
       <div class="box-header"> 
        <p class="box-title"><FONT SIZE=12><?php echo $product->product_name; ?></FONT></p> 
       </div> 
       <div style="height: 80px; text-align: center;"> 
        <?php echo '<img src="'.'uploads/'. $product->photo.'" class="img-responsive" style="height:80px !important; width: 150px !important" />'; ?> 
       </div> 

       <div style="clear: both"></div> 
       <table class="table table-responsive"> 
        <tr> 
         <th><FONT SIZE=12>ID</FONT></th> 
         <td><FONT SIZE=14><?php echo $product->product_id; ?></FONT></td> 
        </tr> 
        <tr> 
         <th><FONT SIZE=12>LKR</FONT></th> 
         <td><FONT SIZE=14><?php $lkr = get_selling_price($product); 
          echo number_format(round($lkr, get_option('round_precision'))); ?></FONT> 
         </td> 
        </tr> 
        <tr> 
         <th> <FONT SIZE=12>US $</FONT></th> 
         <td><FONT SIZE=14><?php echo number_format(round(lkr_to_usd($lkr), get_option('round_precision'))); ?></FONT></td> 
        </tr> 
       </table> 

     </div> 

      </td> 
     <?php } ?> 

    </tr> 

    <?php } ?> 

    </table> 
</div><!-- /.box-body --> 


</body> 

</body> 
</html> 

当我尝试生成PDF它总是来了这个样子。我在上面添加了我的生成pdf代码。 第二页不会像第一页一样..我搜索并找到其他人的问题的其他dompdf解决方案。但我的问题是第二页,它不是作为第一页。

+0

由于问题不在于你的PHP代码,你能否提供一个传递给dompdf的HTML样本? – BrianS

回答

0

dompdf这里有一些bug的行为。出于某种原因,使用width: 100%对包含您的产品信息的DIV进行造型,会在表格行被分页时破坏布局。如果您从DIV中删除该样式,则该文档应按预期进行渲染。默认的DIV布局是全角,因此你可以在DIV上留下宽度样式