Search code examples
phpsymfonytwigsymfony4

creating dynamic pdf with KnpSnappyBundle and branch


I am creating a dynamic pdf which is a grid that shows notes by semesters, the problem is that if I have semesters I must create the pdf.

Suppose there are 5 semesters or more, it only fits up to 4 semesters. I am using the pdf sheet horizontally.

mallapdf

What I need is that somehow it only allows me to show 4 semesters on a sheet and the rest on another page, but loading the name column again, first name and lastname.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
{% set ArrayMaterias = materias %}
{% set ArrayCalificaciones = calificaciones %}
{% set Semestre = semestre %}
{% set ArrayNombres = nombres %}
{% set Celdas = 8 * Semestre %}
    <table style="table-layout: fixed; width: 100%;" border=1>
        <tbody>
            <tr>
                <td style="width: 20px"></td>
                <th style="width: 400px"></th>
                {# Aca es donde se define cambiar a otra pagina #}
                {% for m in materias %}
                    <th style="width: 400px" colspan="8">{{m}}</th>
                {% endfor %}
            </tr>
            <tr style="height: 120px;">
                <th></th>
                <td>Apellidos y Nombres</td>
                {% for s in 1.. semestre %}
                    {% for c in calificaciones %}
                        <td><p style="writing-mode: vertical-lr; transform: rotate(180deg);">{{c}}</Tarea> </p></td>
                    {% endfor %}
                {% endfor %}
            </tr>
            {% for n in nombres %}
                <tr>
                <th></th>
                <td>{{n}}</td>
                {% for ce in 1.. Celdas %}
                    <td></td>
                {% endfor %}
            </tr>    
            {% endfor %}
            
        </tbody>
    </table>
</body>
</html>

Solution

  • You can break page after 4th item like this.

    <div style="page-break-before:always"></div>
    

    You will probably need to change cycle little bit and print more tables.