Export PDF in Laravel Using Anouar FPDF

How to Export PDF in Laravel Using Anouar FPDFExport PDF in Laravel Using Anouar FPDF – To export data to PDF format in Laravel, requires a PDF library. FPDF is a PDF library is one of the most popular for PHP. FPDF library can not be directly inserted into Laravel, that’s why used Anouar FPDF library that supports installation using Composer, so it can be installed in Laravel.

Anouar FPDF Installation

First, install the library Anouar FPDF with this Composer command (via DOS Prompt) :
->cd \
->cd <htdocs>\<laravel>
->composer require anouar/fpdf


Then open file <laravel>/config/app.php, add the following line :
providers' => [
* Laravel Framework Service Providers...


'aliases' => [
'Fpdf' => Anouar\Fpdf\Facades\Fpdf::class ,


To export the pdf, add this source code to the Controller :
use Fpdf;


public function exportpdf(){
 $pdf = new Fpdf();
 $pdf::cell(35,8,"New York",1,"","L");


Do not forget to add routing, in file <laravel>/app/Http/routes.php add this line :
Route::get('exportpdf', 'YourController@exportpdf'); 

Result Export PDF in Laravel

The result can be run with the url: http: //<laravel>/public/exportpdf
How to Export PDF in Laravel Using Anouar FPDF

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>