mercredi 29 juin 2016

DOMPODF failed in Laravel

I have this method in my controller which export a PDF

    public function export($semester)
    {
        // some code

        $pdf = PDF::loadView('entities.match.pdf', ['profiles' => $profiles, 'semester' => $semester]);

        return $pdf->download('Matches_' . $semester->name . '.pdf');
    }

and my "match.pdf" view

<h3>Matches for {{ $semester->name }}</h3>

@if (count($profiles) == 0)
    No Matches for this semester yet...
@else
    <table border="1" border-spacing: "5px" style="width:100%">
    <thead>
    <tr>
        <td align="center" colspan="2">Local Student</td>
        <td align="center" colspan="2">Incoming Student</td>
    </tr>
    <tr>
        <th> Last, first name</th>
        <th> Course</th>
        <th> Last, first name</th>
        <th> Course</th>
    </tr>
    </thead>
    <tbody>
    @foreach($profiles as $item)
        <tr>
            <td width="20%">
                {{ $item['local']->user->last_name }}, {{ $item['local']->user->first_name }}<br>
                {{ $item['local']->user->email }}
            </td>
            <td width="30%">{{ $item['local']->course->name }}</td>
            <td width="20%">
                {{ $item['incoming']->user->last_name }}, {{ $item['incoming']->user->first_name }}<br>
                {{ $item['incoming']->user->email }}
            </td>
            <td width="30%">{{ $item['incoming']->course->name }}</td>
        </tr>
    @endforeach
    </tbody>
    </table>
@endif

The code is correct and works but if only if the amount of "profiles" is less than about 110. If the "profile" amount is above that number, I get "failed" as the download status in Firefox and Chrome.

Is this a DOMPDF bug? Is my code not right? Any workaround?

Aucun commentaire:

Enregistrer un commentaire