html2pdf how to generate a new page when a table exceeds page size

40
July 12, 2018, at 03:00 AM

I'm trying to generate a pdf file according to the amount of products that are needed.

$html2pdf->writeHTML($this->render($template, array(
        'offerte' => $offerte,
        'customer' => $customer
    ))->getContent());
    try {
        $html2pdf->output();
    } catch (Html2PdfException $e) {
    }

in the html.twig file i loop through the amount of objects inside my $offerte object. but when my objects exceed the page height , i get a 502 bad gateway crash. So when i have like 1 table row it works just fine, but when i have like 40 rows and it's bigger than 1 pdf page it keeps loading and crashes. After checking the logs there's a maximum execution error :

request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalErrorException: "Error: Maximum execution time of 30 seconds exceeded" at /var/www/todo-symfony/vendor/tecnickcom/tcpdf/tcpdf.php line 7776 {"exception":"[object] (Symfony\Component\Debug\Exception\FatalErrorException(code: 0): Error: Maximum execution time of 30 seconds exceeded at /var/www/todo-symfony/vendor/tecnickcom/tcpdf/tcpdf.php:7776)"} []

is there a way to start a new page when i'm having too much table rows on 1 page , or is this error there for another reason?

my html.twig template file that is getting loaded :

<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>

READ ALSO
How to get model&#39;s relation by name?

How to get model's relation by name?

Is there a way to call a relation by it's name?

42
Remove the second instance of a key value pair in a collection

Remove the second instance of a key value pair in a collection

So I am trying to determine if a app is part of a list of apps that are affected by downstream servicesThe following code is what I am currently trying to do:

63
PHP replace web address test in variable

PHP replace web address test in variable

can anyone help with this? I have a web address as a variable and would like to replace multiple web address if they exist

32