Laravel 5.4 and Dompdf - problems?

0

I'm trying to generate a PDF from a view , and it's working fine, however, when I call the route to call controller , the loading stays for several seconds, until minutes to generate the PDF, and download, not to mention that you are not applying my CSS styles. I would like a light, to know what I can do.

PS: use another library only if it is simpler.

View:

<!doctype html>
<html lang="pt-BR">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="{{ asset('css/app.css') }}" rel="stylesheet" type="text/css">
    <title>Lista de chamada</title>
</head>
<body>
    <div class="container">
        <div class="row">
            <div class="col-md-8 col-md-offset-2">
                <div class="panel panel-default">
                    <div class="panel-heading text-center">
                        <h4>Lista de chamada</h4>
                    </div>

                    <div class="panel-body text-center">
                        <table class="table table-striped">
                            <thead>
                                <th>#</th>
                                <th>Cartão SUS</th>
                                <th>Data de nascimento</th>
                                <th>Avaliação alterada</th>
                                <th>Peso</th>
                                <th>Altura</th>
                                <th>Assinatura</th>
                            </thead>
                            <tbody>
                                @foreach($pacientes as $paciente)
                                    <tr>
                                        <td>{{ $loop->iteration }}</td>
                                        <td>{{ $paciente->NumeroCartaoSUS }}</td>
                                        <td>{{ $paciente->DataNascimento }}</td>
                                        <td>{!!
                                                $paciente->AvaliacaoAlterada == 1 ?
                                                    Icon::ok().' Sim' :
                                                    Icon::remove().' Não'
                                            !!}
                                        </td>
                                        <td>{{ $paciente->Peso }}</td>
                                        <td>{{ $paciente->Altura }}</td>
                                        <td>  </td>
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>

Controller:

<?php

namespace Famerp\Http\Controllers\PDF;

use PDF;
use Famerp\Models\Paciente;
use Famerp\Http\Controllers\Controller;

class PDFController extends Controller
{
    public function pdfListaChamada()
    {
        $pacientes = Paciente::all();
        $pdf = PDF::loadView('pdf.pdf-lista-chamada', array('pacientes' => $pacientes));
        return $pdf->setPaper('a4')->download('lista-chamada.pdf');
    }
}

I followed the code guidelines that have on the GitHub page of the project itself, I do not understand why.

    
asked by anonymous 15.07.2017 / 15:21

1 answer

-1

A recommendation for PDF with Laravel that I give is to use the libraries "barryvdh / laravel-snappy" "h4cc / wkhtmltoimage-amd64" and "h4cc / wkhtmltopdf-amd64" in my opinion is the best way to generate PDF in Laravel.

PS: So far I have had no problem with CSS compatibility, images etc

Example:

$pdf = PDF::loadView('pdf.invoice', $data);
return $pdf->download('invoice.pdf');

link

    
31.07.2017 / 05:28