vincentvete/tcpdi
Composer 安装命令:
composer require vincentvete/tcpdi
包简介
PDF importer for TCPDF based on FPDI (supports optimized PDF 1.5+)
README 文档
README
Note: This is a clone of pauln/tcpdi for Composer
TCPDI
If you got stuck with FPDI cannot parse PDF version 1.5+, then try this Perfect for PDF Merge, Combine or Layer Overlapping
Installation
Clone this git & copy it directory contains TCPDF
git clone https://github.com/lthh89vt/tcpdi
Via Composer
composer require lthh89vt/tcpdi
Usage
Usage is essentially the same as FPDI, except importing TCPDI rather than FPDI. It also has a "setSourceData()" function which accepts raw PDF data, for cases where the file does not reside on disk or is not readable by TCPDI.
// Create new PDF document. $pdf = new \TCPDI(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // Add a page from a PDF by file path. $pdf->AddPage(); $pdf->setSourceFile('/path/to/file-to-import.pdf'); $idx = $pdf->importPage(1); $pdf->useTemplate($idx); $pdfdata = file_get_contents('/path/to/other-file.pdf'); // Simulate only having raw data available. $pagecount = $pdf->setSourceData($pdfdata); for ($i = 1; $i <= $pagecount; $i++) { $tplidx = $pdf->importPage($i); $pdf->AddPage(); $pdf->useTemplate($tplidx); }
As of version 1.1, TCPDI also includes additional functionality for handling PDF Annotations. As annotations are positioned relative to the bleed box rather than the crop box, you'll need to ensure that you're importing the full bleed box; a new function has also been introduced to set the page format (the various boxes, including the crop box) from the imported page, so that the imported page matches the original better. The following example demonstrates this:
// Create new PDF document. $pdf = new \TCPDI(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // Add a page from a PDF by file path. $pdf->setSourceFile('/path/to/file-to-import.pdf'); // Import the bleed box (default is crop box) for page 1. $tplidx = $pdf->importPage(1, '/BleedBox'); $size = $pdf->getTemplatesize($tplidx); $orientation = ($size['w'] > $size['h']) ? 'L' : 'P'; $pdf->AddPage($orientation); // Set page boxes from imported page 1. $pdf->setPageFormatFromTemplatePage(1, $orientation); // Import the content for page 1. $pdf->useTemplate($tplidx); // Import the annotations for page 1. $pdf->importAnnotations(1);
Note: tcpdi_parser v1.1 is required in order to import annotations, though setPageFormatFromTemplatePage() should work with older versions of tcpdi_parser.
Credits
vincentvete/tcpdi 适用场景与选型建议
vincentvete/tcpdi 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.29k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 12 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「pdf」 「TCPDF」 「fpdi」 「tcpdi」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vincentvete/tcpdi 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vincentvete/tcpdi 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vincentvete/tcpdi 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Extended FPDF include FPDF, FPDF Protection, HTML2PDF, etc
TCPDF is a PHP class for generating PDF documents and barcodes.
Extension of TCPDF library and FPDI library with added convenience methods.
Composer version of Setasign FPDI-Protection
TCPDI is a PHP class for importing PDF to use with TCPDF
TCPDI is a PHP class for importing PDF to use with TCPDF
统计信息
- 总下载量: 1.29k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-12-16