Reputation: 2379
I want to generate PDF file from a view in laravel5. I found https://github.com/barryvdh/laravel-dompdf and added to my project via composer.
but it is not working,
$pdf = PDF::loadView('invoice', array());
return $pdf->download('invoice.pdf');
Getting error is
ErrorException in InvoiceController.php line 34: Non-static method Barryvdh\DomPDF\PDF::loadView() should not be called statically, assuming $this from incompatible context
Is there any other package for laravel5?
Upvotes: 3
Views: 10344
Reputation: 1
public function export(PDF $pdf, Student $students) {
$students= $students->all();
// $brand = Brands::all();//todo: sort folder and conrtoller
$results=[];
$pdf = $pdf->loadView('dashboard.strs.manage.reports.examreports.exampdfreport',compact('students'));
return $pdf->stream();
}
This method loads the pdf dialog box allows you to save your file as you would prefer.
Upvotes: 0
Reputation: 5443
I worked with 2 method for HTML to PDF
1.MPDF
2.Snappy PDF developed using WKHTML to PDF
Follow those 2 url you can use them using composer require.It will definitely help
For SNAPPY:http://www.kingpabel.com/php-html-to-pdf-snappy/
For MPDF:http://www.kingpabel.com/mpdf-for-php-to-pdf/
Upvotes: 0
Reputation: 393
try:
$pdf = App::make('dompdf');
$pdf->loadView('invoice', array());
return $pdf->download('invoice.pdf');
Regards
Upvotes: 1