2017 © Pedro Peláez
 

library larapdf

PDF document package using laravel

image

peal/larapdf

PDF document package using laravel

  • Sunday, July 29, 2018
  • by moin786
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Laravel Package for FPDF

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)

Installation

Inside your project root directory, open your terminal, (*2)

composer require peal/larapdf

Composer will automatically download all dependencies., (*3)

For Laravel

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,
];

Basic settings

$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();

OR

use peal\larapdf\Facades\Pdf;
Pdf::AddPage()
    ->SetFont('Arial','B',16)
    ->Cell(40,10,'Hello World!')
    ->Output();

Advances Usages without Facades

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();

Advance usages using Facades

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();

For core php

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();

More tutorial from

FPDF, (*11)

Author

Mohammed Minuddin(Peal), (*12)

The Versions

29/07 2018

dev-master

9999999-dev

PDF document package using laravel

  Sources   Download

MIT

The Requires

 

by Moinuddin Chowdhury