dimanche 28 octobre 2018

Learning to use FPDF

I am learning to use a library for PDF document development called Fpdf.

I have this view:

public function imprimir(Articulo $articulo){
    $pdf=new Fpdf();
    $pdf->AddPage();
    $pdf->Image($articulo->foto->ruta(),10,6,30);
    $pdf->SetXY(5,30);
    $pdf->SetFont("Arial",'B',16);
    $pdf->Write(10,$articulo->titulo);
    $pdf->Ln();
    $pdf->SetFont("Arial",'B',12);
    $pdf->Write(9,$articulo->texto);
    $pdf->Ln();
    $pdf->SetFont("Arial","",10);
    $pdf->Write(8,$articulo->user->nombre());
    $pdf->Output();
    exit;
}

And this is the result:

enter image description here

But I like create one PDF file with a view. It's my view, called "pura_noticia.blade.php":

<div class="col-md-6 card card-1">
    <h2 class="text-center card-title"></h2>
    <hr>
    <img class="card-img-top" src=""/>
    <hr>
    <h3 class="text-left"></h3>
    <hr>
    <div class="card-body">
    <center>
        <span class="badge badge-cat badge-info">Noticia publicada por </span>
        <span class="badge badge-cat badge-info">Esta noticia ha sido publicada el </span>
        @if($articulo->created_at<$articulo->updated_at)
            <span class="badge badge-cat badge-info">Fue actualizada por última vez el </span>
        @endif
    </center>
    </div>
</div>

How I can use my view?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2D9zgt1
via IFTTT

Aucun commentaire:

Enregistrer un commentaire