dev-master
9999999-devPDF document package using laravel
MIT
The Requires
by Moinuddin Chowdhury
PDF document package using laravel
FPDF is a PHP class which allows to generate PDF files with pure PHP, that is to say without using the PDFlib library. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs. FPDF has other advantages: high level functions. , (*1)
Inside your project root directory, open your terminal, (*2)
composer require peal/larapdf
Composer will automatically download all dependencies., (*3)
After complete the installation, open your app.php from config folder, paste below line inside providers array, (*4)
peal\larapdf\PdfServiceProvider::class,
For Facade support, paste below line inside aliases array, (*5)
'Pdf' => peal\larapdf\Facades\Pdf::class,
Then run this command, (*6)
php artisan vendor:publish --provider="peal\larapdf\PdfServiceProvider"
After vendor published check your config folder pdf-config.php is created., (*7)
/* * FPDF class * */ return [ 'pdfservice' => peal\larapdf\FPDF::class, ];
$pdf = App::make('pdf'); $pdf->AddPage(); $pdf->SetFont('Arial','B',16); $pdf->Cell(40,10,'Hello World!'); $pdf->Output();
You can chain it, (*8)
$pdf = App::make('pdf'); $pdf->AddPage() ->SetFont('Arial','B',16) ->Cell(40,10,'Hello World!') ->Output();
use peal\larapdf\Facades\Pdf; Pdf::AddPage() ->SetFont('Arial','B',16) ->Cell(40,10,'Hello World!') ->Output();
Inside your Controller method, (*9)
$row_height = 6; $y_axis = 50; $y_axis = $y_axis + $row_height; $pdf = App::make('pdf'); $pdf->AddPage() ->SetFont('Arial','B',16) ->Cell(0,10,"SAIC Institute of Management & Technology",0,0,'C') ->SetFont('Arial','B',12) ->Cell(-65, 30, 'Begum Rokeya Avenue, Dhaka',0,'C',0) ->Cell(-11, 50, 'Phone: 01936-005816',0,'C',0) ->SetFillColor(232, 232, 232) ->SetY(50) ->SetX(25) ->SetFont('Arial', 'B', 10) ->Cell(20, 6, 'Room No', 1, 0, 'L', 1) ->Cell(20, 6, 'Seat No', 1, 0, 'L', 1) ->Cell(30, 6, 'Student ID', 1, 0, 'L', 1) ->Cell(60, 6, 'Student Name', 1, 0, 'L', 1) ->Cell(20, 6, 'Seat Rent', 1, 0, 'L', 1) ->Cell(25, 6, 'Meal Charge', 1, 0, 'L', 1) ->SetY($y_axis) ->SetX(25) ->SetFont('Arial', '', 10) ->Cell(20, 6, 200, 1, 0, 'L', 1) ->Cell(20, 6, 201, 1, 0, 'L', 1) ->Cell(30, 6, 'CMT2018002', 1, 0, 'L', 1) ->Cell(60, 6, "Saiful Islam", 1, 0, 'L', 1) ->Cell(20, 6, 2000, 1, 0, 'L', 1) ->Cell(25, 6, 50, 1, 0, 'L', 1) ->Output();
Inside your Controller method, (*10)
use peal\larapdf\Facades\Pdf; $row_height = 6; $y_axis = 50; $y_axis = $y_axis + $row_height; Pdf::AddPage() ->SetFont('Arial','B',16) ->Cell(0,10,"SAIC Institute of Management & Technology",0,0,'C') ->SetFont('Arial','B',12) ->Cell(-65, 30, 'Begum Rokeya Avenue, Dhaka',0,'C',0) ->Cell(-11, 50, 'Phone: 01936-005816',0,'C',0) ->SetFillColor(232, 232, 232) ->SetY(50) ->SetX(25) ->SetFont('Arial', 'B', 10) ->Cell(20, 6, 'Room No', 1, 0, 'L', 1) ->Cell(20, 6, 'Seat No', 1, 0, 'L', 1) ->Cell(30, 6, 'Student ID', 1, 0, 'L', 1) ->Cell(60, 6, 'Student Name', 1, 0, 'L', 1) ->Cell(20, 6, 'Seat Rent', 1, 0, 'L', 1) ->Cell(25, 6, 'Meal Charge', 1, 0, 'L', 1) ->SetY($y_axis) ->SetX(25) ->SetFont('Arial', '', 10) ->Cell(20, 6, 200, 1, 0, 'L', 1) ->Cell(20, 6, 201, 1, 0, 'L', 1) ->Cell(30, 6, 'CMT2018002', 1, 0, 'L', 1) ->Cell(60, 6, "Saiful Islam", 1, 0, 'L', 1) ->Cell(20, 6, 2000, 1, 0, 'L', 1) ->Cell(25, 6, 50, 1, 0, 'L', 1) ->Output();
use peal\larapdf\Mediator\Pdf; use peal\larapdf\FPDF; $pdf = new Pdf(new FPDF()); $pdf->AddPage(); $pdf->SetFont('Arial','B',16); $pdf->Cell(40,10,'Hello World!'); $pdf->Output();
FPDF, (*11)
Mohammed Minuddin(Peal), (*12)
PDF document package using laravel
MIT