2016-04-15 189 views
1

我正在使用mpdf php库为我的发票生成pdf。 在发票中,我列出了使用表格列出的产品。但是,当我的产品列表在pdf上增加了所有产品挤在单页上。 请帮忙。以下是我的代码内容溢出时自动分页 - mpdf

谢谢先进。

<table width="100%" cellpadding="0" cellspacing="0"> 
    <tr> 
     <td width="8%" class="left-stripes"></td> 

     <td width="92%" class="right-invoice"> 
      <table width="100%" cellpadding="0" cellspacing="0"> 
       <tr> 
        <td width="50%" class="billed-to-info"> 
         Billed To, 
         <h3>Party Name</h3> 
         Party Detailed Address <br> 
         0124-234564 <br> 
        </td> 
        <td width="50%" align="right"><img src="<?php echo base_url(); ?>assets/img/tophead.jpg" class="topHeaderImageRight" /></td> 
       </tr> 
       <tr> 
        <td class="order-info" valign="top" style="padding-top: 20px;padding-left:10px;"> 
         Order ID: #602 <br /> 
         Delivery Date: 25 April 2016 
        </td> 
        <td class="billed-to-info" style="padding-top: 20px;"> 
         <span>Billed By,</span> 
         <h3>Party Name</h3> 
         Party Address Details <br> 
         0712-277 4770 <br> 
        </td> 
       </tr> 
      </table> 
      <br /> 

      <table width="100%" cellpadding="0" cellspacing="0" class="product-list-table"> 
       <tr style="background-color: #F5F5F5 !important;"> 
        <th class="productinfo-header text-center"></th> 
        <th class="productinfo-header text-left">Item</th> 
        <th class="productinfo-header text-center">Mfg. Date</th> 
        <th class="productinfo-header text-center">Expiry Date</th> 
        <th class="productinfo-header text-right">QTY</th> 
        <th class="productinfo-header text-right">MRP</th> 
        <th class="productinfo-header text-right">Rate</th> 
        <th class="productinfo-header text-right">Total</th> 
       </tr> 
       <?php 
        for ($i=0; $i < 22; $i++) { 
       ?> 
       <tr> 
        <td width="5%" class="productinfo-list text-center">1</td> 
        <td width="28%" class="productinfo-list text-left">Haldi Powder (100 gm)</td> 
        <td width="15%" class="productinfo-list text-center line-height-21"> 
         01 Feb 16 (10) <br /> 
         01 Mar 16 (30) 
        </td> 
        <td width="15%" class="productinfo-list text-center line-height-21"> 
         01 Oct 16(10) <br /> 
         01 Nov 16(30) 
        </td> 
        <td width="8%" class="productinfo-list text-right">40</td> 
        <td width="8%" class="productinfo-list text-right">60.00</td> 
        <td width="8%" class="productinfo-list text-right">55.23</td> 
        <td width="13%" class="productinfo-list text-right">5246.00</td> 
       </tr> 

       <tr> 
        <td class="productinfo-list text-center">12</td> 
        <td class="productinfo-list text-left">Haldi Powder (200 gm)</td> 
        <td class="productinfo-list text-center">01 Feb 16</td> 
        <td class="productinfo-list text-center">01 Oct 16</td> 
        <td class="productinfo-list text-right">10</td> 
        <td class="productinfo-list text-right">110.00</td> 
        <td class="productinfo-list text-right">90.23</td> 
        <td class="productinfo-list text-right">902.30</td> 
       </tr> 
       <?php } ?> 
       <tr> 
        <td colspan="4" rowspan="4" class="productinfo-list line-height-21"> 
         <span>Buyer's VAT: 1234566</span><br /> 
         <span>Seller's VAT: 326541233</span><br /> 
         <span>Account Number: 12354647</span><br /> 
         <span>IFSC Code: BFGH1234</span> 
        </td> 
        <td colspan="3" class="productinfo-list">Gross Total</td> 
        <td class="productinfo-list text-right">6100.23</td> 
       </tr> 

       <tr> 
        <td colspan="3" class="productinfo-list">Scheme Discount</td> 
        <td class="productinfo-list text-right">100.23</td> 
       </tr> 
       <tr> 
        <td colspan="3" class="productinfo-list">VAT</td> 
        <td class="productinfo-list text-right">531.10</td> 
       </tr> 
       <tr> 
        <td colspan="3" class="productinfo-list">Net Total</td> 
        <td class="productinfo-list text-right">6500.10</td> 
       </tr> 
      </table> 
      <pagebreak /> 
      <br /><br />     
     </td> 
    </tr> 
</table> 

回答

1

它是如何看,如果你只输出 “清单” 表格:

<table width="100%" cellpadding="0" cellspacing="0" class="product-list-table"> 

运行与($ i = 0; $ I < 99; $ I ++)一个测试,如果告诉我问题是一样的。 beste regards, dd

+0

其工作你说什么。但最新的问题,因为我需要像上面的完整代码..? –

0

TCPDF在HTML表中存在问题。你必须简化你的代码。 尝试HTML这样的:

<table width="100%" cellpadding="0" cellspacing="0"> 
<tr> 
    <td width="8%" class="left-stripes"></td> 

    <td width="92%" class="right-invoice"> 
     <table width="100%" cellpadding="0" cellspacing="0"> 
      <tr> 
       <td width="50%" class="billed-to-info"> 
        Billed To, 
        <h3>Party Name</h3> 
        Party Detailed Address <br> 
        0124-234564 <br> 
       </td> 
       <td width="50%" align="right"><img src="<?php echo base_url(); ?>assets/img/tophead.jpg" class="topHeaderImageRight" /></td> 
      </tr> 
      <tr> 
       <td class="order-info" valign="top" style="padding-top: 20px;padding-left:10px;"> 
        Order ID: #602 <br /> 
        Delivery Date: 25 April 2016 
       </td> 
       <td class="billed-to-info" style="padding-top: 20px;"> 
        <span>Billed By,</span> 
        <h3>Party Name</h3> 
        Party Address Details <br> 
        0712-277 4770 <br> 
       </td> 
      </tr> 
     </table> 
    </td> 
</tr> 
</table> 
<table width="100%" cellpadding="0" cellspacing="0" class="product-list-table"> 
<tr style="background-color: #F5F5F5 !important;"> 
    <th width="8%" class="productinfo-header"></th> 
    <th class="productinfo-header text-center"></th> 
    <th class="productinfo-header text-left">Item</th> 
    <th class="productinfo-header text-center">Mfg. Date</th> 
    <th class="productinfo-header text-center">Expiry Date</th> 
    <th class="productinfo-header text-right">QTY</th> 
    <th class="productinfo-header text-right">MRP</th> 
    <th class="productinfo-header text-right">Rate</th> 
    <th class="productinfo-header text-right">Total</th> 
</tr> 
<?php for ($i=0; $i < 22; $i++) { ?> 
<tr> 
    <td width="8%" class="productinfo-list text-center"></td> 
    <td width="5%" class="productinfo-list text-center">1</td> 
    <td width="28%" class="productinfo-list text-left">Haldi Powder (100 gm)</td> 
    <td width="15%" class="productinfo-list text-center line-height-21"> 
     01 Feb 16 (10) <br /> 
     01 Mar 16 (30) 
    </td> 
    <td width="15%" class="productinfo-list text-center line-height-21"> 
     01 Oct 16(10) <br /> 
     01 Nov 16(30) 
    </td> 
    <td width="8%" class="productinfo-list text-right">40</td> 
    <td width="8%" class="productinfo-list text-right">60.00</td> 
    <td width="8%" class="productinfo-list text-right">55.23</td> 
    <td width="13%" class="productinfo-list text-right">5246.00</td> 
</tr> 

<tr> 
    <td width="8%" class="productinfo-list"></td> 
    <td class="productinfo-list text-center">12</td> 
    <td class="productinfo-list text-left">Haldi Powder (200 gm)</td> 
    <td class="productinfo-list text-center">01 Feb 16</td> 
    <td class="productinfo-list text-center">01 Oct 16</td> 
    <td class="productinfo-list text-right">10</td> 
    <td class="productinfo-list text-right">110.00</td> 
    <td class="productinfo-list text-right">90.23</td> 
    <td class="productinfo-list text-right">902.30</td> 
</tr> 
<?php } ?> 
<tr><td>&nbsp;</td></tr> 

<tr> 
    <td width="8%" class="productinfo-list"></td> 
    <td colspan="4" rowspan="4" class="productinfo-list line-height-21"> 
     <span>Buyer's VAT: 1234566</span><br /> 
     <span>Seller's VAT: 326541233</span><br /> 
     <span>Account Number: 12354647</span><br /> 
     <span>IFSC Code: BFGH1234</span> 
    </td> 
    <td colspan="3" class="productinfo-list">Gross Total</td> 
    <td class="productinfo-list text-right">6100.23</td> 
</tr> 

<tr> 
    <td width="8%" class="productinfo-list"></td> 
    <td colspan="3" class="productinfo-list">Scheme Discount</td> 
    <td class="productinfo-list text-right">100.23</td> 
</tr> 
<tr> 
    <td width="8%" class="productinfo-list"></td> 
    <td colspan="3" class="productinfo-list">VAT</td> 
    <td class="productinfo-list text-right">531.10</td> 
</tr> 
<tr> 
    <td width="8%" class="productinfo-list"></td> 
    <td colspan="3" class="productinfo-list">Net Total</td> 
    <td class="productinfo-list text-right">6500.10</td> 
</tr> 
</table> 

此解决前人的精力,你的问题。 此致敬礼, 戴夫