mercredi 28 octobre 2015

Laravel 5.1 domPDF not working correctly

hope somebody can help me, I'm trying to generate a report for PDF, so I use barryvdh/laravel-dompdf, maybe the implementetion is wrong, or maybe is just a detail.

The generation works fine, so what I'm trying to do is pass the html as string through a GET AJAX to the controller handling the PDF creator, but when I'm trying to return the PDF is not doing anything. And I'm getting two types of response, one is an error The Response content must be a string or object implementing __toString(), "object" given.

The other thing is that in the debug console returns like garbage.

Here's my controller:

public function generarPDF(Request $request){
        $datos = $request->all();
        $datos = $datos['data'];

        $datos = utf8_encode($datos);

        $data = [];
        $data['html'] = $datos;


        /* Here it return the Error:
        The Response content must be a string or object implementing __toString(), "object" given.*/
        return \PDF::loadView('reportes.pdf', compact('data') );

        /*If I do this it returns nothing, only in the response console throws like garbage...*/
        //return $pdf->download("Hello.pdf");

    }

Thanks...



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire