elibyy/tcpdf-laravel
Composer 安装命令:
composer require elibyy/tcpdf-laravel
包简介
tcpdf support for Laravel 6, 7, 8, 9, 10, 11
README 文档
README
A simple Laravel service provider with some basic configuration for including the TCPDF library
TCPDF is not really supported in PHP 7 but there's a plan for supporting it, check this out.
Installation
The Laravel TCPDF service provider can be installed via composer by requiring the elibyy/tcpdf-laravel package in your project's composer.json. (The installation may take a while, because the package requires TCPDF. Sadly its .git folder is very heavy)
composer require elibyy/tcpdf-laravel
or
Laravel 5.5+ will use the auto-discovery function.
{
"require": {
"elibyy/tcpdf-laravel": "^9.0"
}
}
If you don't use auto-discovery you will need to include the service provider / facade in config/app.php.
'providers' => [ //... Elibyy\TCPDF\ServiceProvider::class, ] //... 'aliases' => [ //... 'PDF' => Elibyy\TCPDF\Facades\TCPDF::class ]
(Please note: TCPDF cannot be used as an alias)
for lumen you should add the following lines:
$app->register(Elibyy\TCPDF\ServiceProvider::class); class_alias(Elibyy\TCPDF\Facades\TCPDF::class, 'PDF');
That's it! You're good to go.
Here is a little example:
use PDF; // at the top of the file PDF::SetTitle('Hello World'); PDF::AddPage(); PDF::Write(0, 'Hello World'); PDF::Output('hello_world.pdf');
another example for generating multiple PDF's
use PDF; // at the top of the file for ($i = 0; $i < 5; $i++) { PDF::SetTitle('Hello World'.$i); PDF::AddPage(); PDF::Write(0, 'Hello World'.$i); PDF::Output(public_path('hello_world' . $i . '.pdf'), 'F'); PDF::reset(); }
For a list of all available function take a look at the TCPDF Documentation
Configuration
Laravel-TCPDF comes with some basic configuration. If you want to override the defaults, you can publish the config, like so:
php artisan vendor:publish --provider="Elibyy\TCPDF\ServiceProvider"
Now access config/tcpdf.php to customize.
- use_original_header is to used the original
Header()from TCPDF.- Please note that
PDF::setHeaderCallback(function($pdf){})overrides this settings.
- Please note that
- use_original_footer is to used the original
Footer()from TCPDF.- Please note that
PDF::setFooterCallback(function($pdf){})overrides this settings.
- Please note that
- use_fpdi is so that our internal helper will extend
TcpdfFpdiinstead ofTCPDF.- Please note fpdi is not a dependency in my project so you will have to follow their install instructions here
Header/Footer helpers
I've got a pull-request asking for this so I've added the feature
now you can use PDF::setHeaderCallback(function($pdf){}) or PDF::setFooterCallback(function($pdf){})
elibyy/tcpdf-laravel 适用场景与选型建议
elibyy/tcpdf-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.88M 次下载、GitHub Stars 达 355, 最近一次更新时间为 2016 年 02 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「pdf」 「TCPDF」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 elibyy/tcpdf-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 elibyy/tcpdf-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 elibyy/tcpdf-laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
TCPDF is a PHP class for generating PDF documents and barcodes.
TCPDI is a PHP class for importing PDF to use with TCPDF
TCPDI is a PHP class for importing PDF to use with TCPDF
Modified version of TCPDF that includes option for setting barcode's bar width
Provides TCPDF integration for Symfony
Alfabank REST API integration
统计信息
- 总下载量: 2.88M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 363
- 点击次数: 30
- 依赖项目数: 7
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-02-10