How to use TCPDF on LARAVEL 4
html, laravel, laravel-4, php, tcpdf
Solution
The definitive version of TCPDF can be added to your Laravel application by adding the tecnick.com/tcpdf package to your composer.json file as follows:
"require": {
"laravel/framework": "4.0.*",
"tecnick.com/tcpdf": "6.0.*", // This is the line to add
Running `composer update` will add the library to your project.
You can then instantiate instances of `TCPDF` and work with it as per the documentation.
Here's an example of a method that you could add to a controller that would construct a very simple PDF file and send it to the browser for download:
public function getPdftest()
{
$pdf = new TCPDF();
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
$pdf->AddPage();
$pdf->Text(90, 140, 'This is a test');
$filename = storage_path() . '/test.pdf';
$pdf->output($filename, 'F');
return Response::download($filename);
}
Problem
Good Day, Can anyone help me how to use TCPDF in Laravel 4, I mean from installing on via composer update to generating a pdf from the view or through the controller. Ive tried to search on Google but I cant find a comprehensive tutorial on how to use it on Laravel 4. Sorry for this noobish question :) . Thanks for the help. I will really appreciate it. Have a good day!