Reputation: 35
use Illuminate\Http\Request;
use PDF;
class PDFController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function generatePDF()
{
$data = [
'title' => 'hello world',
'date' => date('m/d/Y')
];
$pdf = PDF::loadView('myPDF', $data);
return $pdf->download('itsolutionstuff.pdf');
}
}
Upvotes: 2
Views: 3894
Reputation: 117
just in case anyone still looks at this i needed composer require barryvdh/laravel-dompdf
--dev
An easy miss i guess..
Upvotes: 0
Reputation: 4459
Step 1:-
composer require barryvdh/laravel-dompdf
step-2:-
In ..\config\app.php
'providers' => [
Barryvdh\DomPDF\ServiceProvider::class,
],
'aliases' => [
'PDF' => Barryvdh\DomPDF\Facade::class,
]
step 3:-
use \PDF;
Step 4:-
$pdf = PDF::loadView('pdf.file_name');
return $pdf->stream('file_name.pdf', array('Attachment' => 0));
Step 5:-
php artisan cache:clear
// and
php artisan config:cache
Upvotes: 2