mercredi 3 avril 2019

Dompf prints extra table headers on a new page in laravel

I am generating a student transcript in a table format which will be downloaded to pdf using Laravel and Dompdf. The table header is printed multiple times on the second page before the table row and the table data is printed.

I have added the

page-break-inside: avoid !important
style but still having the same issue.

Here are the codes:

<table style="width: 100%;" class="minimalistBlack">
        <?php $semester = 1 ?>
        <?php $tcl = 0 ?>
        <?php $tgp = 0 ?>
        <?php $cgpa = 0 ?>
        <?php $n = 1 ?>
        @foreach($results as $result)
            <thead>
                <tr>
                 <td colspan="2" style="font-weight: bold;">SESSION:</td>
                    <td style="font-weight: bold;"></td>
                    <td colspan="2" style="font-weight: bold;">SEMESTER:</td>
                    <td style="font-weight: bold;"></td>
                </tr>
                <tr>
                    <th>#</th>
                    <th>Course Code</th>
                    <th>Course Title</th>
                    <th style="text-align: center;">Credit Unit</th>
                    <th style="text-align: center;">Grade</th>
                    <th style="text-align: center;">Grade Points</th>
                </tr>
            </thead>

            <tbody>
                <?php $sn = 1 ?>
                <?php $totalGrades = 0 ?>
                <?php $totalCredits = 0 ?>
                @foreach($result->grade as $grade)
                    <tr>
                        <td>.</td>
                        <td></td>
                        <td></td>
                        <td style="text-align: center;"></td>
                        <td style="text-align: center;"></td>
                        <td style="text-align: center;"></td>
                    </tr>
                    <?php $sn++ ?>
                    <?php $totalCredits += $grade->course->credit_unit ?>
                    <?php $totalGrades += calculateGradePoints($grade->grade, $grade->course->credit_unit) ?>
                    <?php $n++ ?>
                @endforeach
                <tr>
                    <td style="font-weight: bold; text-align: right;" colspan="3">TOTAL FOR SEMESTERS</td>
                    <td style="font-weight: bold; text-align: center;"></td>
                    <td class="text-center"></td>
                    <td style="font-weight: bold; text-align: center;"></td>
                </tr>
                <?php $tcl += $totalGrades ?>
                <?php $tgp += $totalCredits ?>
                <?php $cgpa = $tcl / $tgp ?>
                @if($semester > 1)
                    <tr>
                        <td style="font-weight: bold; text-align: right;" colspan="3">TCL</td>
                        <td style="font-weight: bold; text-align: center; color: blue;" colspan="3"></td>
                    </tr>
                    <tr>
                        <td style="font-weight: bold; text-align: right;" colspan="3">TGP FOR ( SESSION) - </td>
                        <td style="font-weight: bold; text-align: center; color: green;" colspan="3"></td>
                    </tr>
                    <tr>
                        <td style="font-weight: bold; text-align: right;" colspan="3">CGPA FOR ( SESSION) - </td>
                        <td style="font-weight: bold; text-align: center; color: red;" colspan="3"></td>
                    </tr>
                @endif
                <tr>
                    <td colspan="6"></td>
                </tr>
            </tbody>
            <?php $semester++ ?>
            <?php $n++ ?>
        @endforeach
    </table>

I want the table data to display on the 2nd page without having to print the table header multiple times.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire