问题
I am getting error 'Class "Fpdf" not found'.
use Fpdf;
Fpdf::AddPage();
Fpdf::SetFont('Courier', 'B', 18);
Fpdf::Cell(50, 25, 'Hello World!');
Fpdf::Output();
回答1:
- Install using Composer
composer require codedge/laravel-fpdf
Add the following lines to your
config/app.php
'providers' => [ // ... Codedge\Fpdf\FpdfServiceProvider::class, ], 'aliases' => [ // ... 'Fpdf' => Codedge\Fpdf\Facades\Fpdf::class, ]
Use it (omit
use Fpdf
):Fpdf::AddPage(); Fpdf::SetFont('Courier', 'B', 18); Fpdf::Cell(50, 25, 'Hello World!'); Fpdf::Output();
or
$fpdf = new Codedge\Fpdf\Fpdf\Fpdf(); $fpdf->AddPage(); $fpdf->SetFont('Courier', 'B', 18); $fpdf->Cell(50, 25, 'Hello World!'); $fpdf->Output();
来源:https://stackoverflow.com/questions/47348486/how-to-generate-fpdf