mardi 6 mars 2018

PDF not displaying in Laravel

I have created a PDF file in Laravel 5 project, I have installed the Laravel PDF package: barryvdh/laravel-dompdf and configured the config/app.php file as required. The problem is that when I load the file on the browser I get an error of This PDF document cannot be displayed properly . Please assist? Not sure if is an issue concerning MIME type..

Controller

class PDFController extends Controller
{
    //Loads the PDF document
    public function getPDF(){
        $pdf = PDF::loadView('pdf.customer');
        return $pdf->stream('customer.pdf');
    }
}

pdf/Customer.blade.php view

<!DOCTYPE html>
<html> 
<head>
    <title> PDF document </title>
    <style>
        h2{
            color:red;
        }
    </style>
</head>
<body>
    <h2> Hello</h2>
    <p> Thank you for contacting us </p>
</body>
 </html>



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

Aucun commentaire:

Enregistrer un commentaire