内容溢出时自动分页 - mpdf

时间:2016-04-15 09:29:57

标签: php codeigniter mpdf

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

谢谢先进。

ng-checked="true"

2 个答案:

答案 0 :(得分:1)

如果你只是输出"列表"它看起来怎么样?表:

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

使用($ i = 0; $ i&lt; 99; $ i ++)运行测试并告诉我问题是否相同。 亲切的问候, DD

答案 1 :(得分: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>

这可以解决您的问题。

致以最诚挚的问候,

戴夫