tonystore / fpdf-laravel
用于在Laravel中使用FPDF库的包
v1.0.0
2021-08-17 00:32 UTC
Requires
- php: ^7.2.5|^8.0
Requires (Dev)
- phpunit/phpunit: ~5.0
This package is auto-updated.
Last update: 2024-09-24 11:15:47 UTC
README
此包使用FPDF并与Laravel集成,基于crabbly/fpdf-laravel包,但使用更新版本的FPDF。
通过Composer安装
步骤1:Composer
在控制台中运行以下命令。
composer require tonystore/fpdf-laravel
步骤2:服务提供者
对于您的Laravel应用,打开config/app.php
文件,并在providers
数组中追加
Tonystore\Fpdf\FpdfServiceProvider::class
使用方法
我们可以从容器中解析FPDF类实例
$pdf = app('Fpdf');
或者
$pdf = new Fpdf();
示例
创建一个“Hello World”PDF文档并在浏览器中显示
use Illuminate\Support\Facades\Storage; //create pdf document $pdf = new Fpdf('P', 'mm', 'A4'); //Attributes assigned to the document. $pdf->AddPage(); $pdf->SetFont('Arial','B',16); $pdf->Cell(40,10,'Hello World!'); $pdf->Output(); // 'I' is the default output. exit;