ghidev/fpdf

一个提供 FPDF 类功能给 Laravel 5 的包

1.0.3 2019-03-20 23:13 UTC

This package is auto-updated.

Last update: 2024-09-21 20:20:46 UTC


README

ghidev/fpdf 是一个用于在 PHP 中动态生成 PDF 文档的类。此外,它还包括用于创建多单元格表格和围绕特定中心点进行旋转的类。

使用 Composer 进行安装

如果你使用 composer 来管理你的包,你可以使用

$ composer require ghidev/fpdf:dev-master

或者,你可以在你的 composer.json 文件中包含以下代码

{
    "require": {
        "ghidev/fpdf": "dev-master"
    }
}

然后,执行 composer update 来下载它。

service providers 添加到 app/config/app.php 文件中的 providers 数组内。

'providers' => array(
	// ...
    
    Ghidev\Fpdf\FpdfServiceProvider::class,
    Ghidev\Fpdf\RotationServiceProvider::class,
    Ghidev\Fpdf\MC_TableServiceProvider::class,
)

最后,将 alias 添加到 app/config/app.php 文件中的 aliases 数组内。

'aliases' => array(
	// ...

	'Fpdf'      => Ghidev\Fpdf\Facades\Fpdf::class,
    'Rotation'    => Ghidev\Fpdf\Facades\Rotation::class,
    'MC_Table'  => Ghidev\Fpdf\Facades\MC_Table::class,
)

##代码示例

Route::get('pdf', function(){

    $fpdf = new Ghidev\Fpdf\Fpdf;
    $fpdf->AddPage();
    $fpdf->SetFont('Arial','B',16);
    $fpdf->Cell(40,10,'Hello World!');
    $fpdf->Output();
    exit;

});

##或者

Route::get('pdf', function(){

    Fpdf::AddPage();
    Fpdf::SetFont('Arial','B',16);
    Fpdf::Cell(40,10,'Hello World!');
    Fpdf::Output();
    exit;
});