CodeIgniter Laravel PHP Example HTML Javascript jQuery MORE Videos New

How to use FPDF in your Laravel


First install the FPDF package

$ composer require codedge/laravel-fpdf

Creating a PDF from your Controller:

UserController.php

<?php
namespace App\Controllers;
 
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Codedge\Fpdf\Fpdf\Fpdf;
 
class PDFController extends Controller
{
   private $fpdf;
 
    public function __construct()
    {
         
    }
 
    public function createPDF()
    {
        $this->fpdf = new Fpdf;
        $this->fpdf->AddPage("L", ['100', '100']);
        $this->fpdf->Text(10, 10, "Hello FPDF");       
         
        $this->fpdf->Output();
        exit;
    }
}