Learning to use FPDF

0

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

I have this code:

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 generates me:

The story is that in DomPDF I could create a PDF file using a view. Can I do the same with Fpdf? It would be the most comfortable for me.

This is the view I want to use, called pura_noticia.blade.php:

<div class="col-md-6 card card-1">
    <h2 class="text-center card-title">{{$articulo->titulo}}</h2>
    <hr>
    <img class="card-img-top" src="{{url($articulo->foto->ruta())}}"/>
    <hr>
    <h3 class="text-left">{{$articulo->texto}}</h3>
    <hr>
    <div class="card-body">
    <center>
        <span class="badge badge-cat badge-info">Noticia publicada por {{$articulo->user->nombre()}}</span>
        <span class="badge badge-cat badge-info">Esta noticia ha sido publicada el {{$articulo->created_at}}</span>
        @if($articulo->created_at<$articulo->updated_at)
            <span class="badge badge-cat badge-info">Fue actualizada por última vez el {{$articulo->updated_at}}</span>
        @endif
    </center>
    </div>
</div>
    
asked by Miguel Alparez 26.10.2018 в 09:41
source

0 answers