apsg/certificate

0.1.0 2021-04-30 11:12 UTC

README

Latest Version on Packagist Total Downloads Build Status StyleCI

这是一个辅助包,用于提供简单的PDF证书生成功能。它底层使用FPDI/FPDF,并配置为支持波兰语。它作为Laravel 5/6的包工作,但并没有添加很多Laravel特定的功能,因此也可以在其他项目中使用。

安装

通过Composer

$ composer require apsg/certificate

使用方法

use Apsg\Certificate\Certificate;
use Apsg\Certificate\Fields\Field;
use Apsg\Certificate\Formats\A4LandscapeFormat;

class CertificateController extends Controller
{
    /**
     * This will output the pdf to browser to download
     */
    public function test()
    {
        $certificate = new Certificate(null, new A4LandscapeFormat());

        return $certificate
            ->setBackground(storage_path('app/public/tlo.png'))
            ->addField(new Field('test zażółć gęślą', 10, 100, 20))
            ->generate();
    }
}
 

注意:背景会被拉伸以填充页面,因此请使用适当的分辨率和方向以获得最佳效果。

测试

$ composer test