2016-04-15 79 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> 

此解決前人的精力,你的問題。 此致敬禮, 戴夫