CodeIgniter Laravel PHP Example HTML Javascript jQuery MORE Videos New
Need a Website Or Web Application.Contact : +91 9437911966 (Whatsapp) Note: Paid Service

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;
    }
}