html2pdf当表格超过页面大小时如何生成新页面

时间:2018-07-11 16:37:28

标签: php html twig symfony-3.4 html2pdf

我正在尝试根据所需产品的数量生成pdf文件。

$html2pdf->writeHTML($this->render($template, array(
        'offerte' => $offerte,
        'customer' => $customer
    ))->getContent());
    try {
        $html2pdf->output();
    } catch (Html2PdfException $e) {
    }
我在html.twig文件中循环遍历$ offerte对象内的对象数量。但是,当我的对象超过页面高度时,我遇到502错误的网关崩溃。因此,当我有1个表行时,它工作得很好,但是当我有40个行时,并且它比1个pdf页面大时,它将不断加载并崩溃。检查日志后,出现最大执行错误:

  

request.CRITICAL:未捕获的PHP异常   Symfony \ Component \ Debug \ Exception \ FatalErrorException:“错误:最大值   执行时间超过30秒”   /var/www/todo-symfony/vendor/tecnickcom/tcpdf/tcpdf.php第7776行   {“例外”:“ [对象]   (Symfony \ Component \ Debug \ Exception \ FatalErrorException(代码:0):   错误:超过了30秒的最大执行时间   /var/www/todo-symfony/vendor/tecnickcom/tcpdf/tcpdf.php:7776)“} []

当我在一页上有太多表行时,是否有一种方法可以开始新页面,还是因为另一个原因而出现此错误?

我的正在加载的html.twig模板文件:

<page backtop="7mm" backbottom="7mm" backleft="10mm" backright="10mm">
<page_header>
    <img class="banner" src="img/cue/offerte_header.JPG"/><br>
    <div class="row customer_info">
        <table>
            <tbody>
            <tr>
                <td width="90">Naam :</td>
                <td width="225">{{ customer.firstName }} {{ customer.lastName }}</td>
                <td width="90">Lever adres :</td>
                <td width="225">{{ offerte.deliveryaddress }} {{ offerte.postcode }} {{ offerte.place }}</td>
            </tr>
            <tr>
                <td width="90">Adres :</td>
                <td width="225">{{ customer.address }} {{ customer.postcode }} {{ customer.place }}</td>
                <td width="90">Lever datum :</td>
                <td width="225">{{ offerte.deliverydate|date("d/m/Y") }}</td>
            </tr>
            <tr>
                <td>Telefoon :</td>
                <td>{{ customer.phone }}</td>
            </tr>
            </tbody>
        </table>
    </div>
    <table class="data_table" width="780px">
        <col width="50">
        <col width="505">
        <col width="50">
        <col width="50">
        <col width="50">
        <thead>
        <tr>
            <th align="center" class="data_table">Code</th>
            <th align="center" class="data_table">Omschrijving</th>
            <th align="center" class="data_table">Aantal</th>
            <th align="center" class="data_table">Prijs</th>
            <th align="center" class="data_table">Totaal</th>
        </tr>
        </thead>
        <tbody>
        {% set totaal = 0 %}
        {% for object in offerte.objects %}
            <tr>
                <td class="data_table">{{ object.code }}</td>
                <td class="data_table"><pre>{{ object.omschrijving }}</pre></td>
                <td class="data_table">{{ object.aantal }}</td>
                <td class="data_table">€ {{ object.prijs }}</td>
                <td class="data_table">€ {{ object.totaal }}</td>
                {#{% set totaal = totaal + object.totaal %}#}
            </tr>
        {% endfor %}
        <tr>
            <td></td>
            <td></td>
            <td colspan="2" align="right" class="left-center">Subtotaal</td>
            <td class="data_table_foot">€ {{ totaal }} </td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td colspan="2" align="right" class="left-center">Korting</td>
            <td class="data_table_foot">{{ offerte.korting }} %</td>
        </tr>
        <tr>
            <td></td>
            <td colspan="3" align="right" class="left-center">Opbouw/afbouw + transport</td>
            <td class="data_table_foot">€ {{ offerte.extracost }} </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="3" align="right" class="left-center">BTW</td>
            <td class="data_table_foot">{{ offerte.btw }} %</td>
        </tr>
        <tr>
            <td></td>
            <td colspan="3" align="right" class="left-center">Totaal</td>
            {#{% set h1 = totaal - (totaal / 100 * offerte.korting) %}#}
            {#{% set h2 = h1 + offerte.extracost %}#}
            {#{% set h3 = h2 +  (h2 / 100 * offerte.btw) %}#}
            <td class="data_table_foot">€ {{ h3|round(2) }} </td>
        </tr>
        </tbody>
    </table>
</page_header>
<page_footer>
    <img class="bannerfooter" src="img/cue/offerte_footer.JPG"/><br>
</page_footer>

0 个答案:

没有答案