承接 setasign/fpdi 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

setasign/fpdi

Composer 安装命令:

composer require setasign/fpdi

包简介

FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Because it is also possible to use FPDI with TCPDF, there are no fixed dependencies defined. Please see suggestions for packages which evaluates the dependencies a

README 文档

README

Latest Stable Version Total Downloads License

❗ This document refers to FPDI 2. Version 1 is deprecated and development is discontinued. ❗

FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF, which was developed by Olivier Plathey. Apart from a copy of FPDF, FPDI does not require any special PHP extensions.

FPDI can also be used as an extension for TCPDF or tFPDF.

Installation with Composer

Because FPDI can be used with FPDF, TCPDF or tFPDF, we haven't added a fixed dependency in the main composer.json file. You need to add the dependency to the PDF generation library of your choice yourself.

To use FPDI with FPDF, include the following in your composer.json file:

{
    "require": {
        "setasign/fpdf": "1.9.*",
        "setasign/fpdi": "^2.6"
    }
}

If you want to use TCPDF, you have to update your composer.json to:

{
    "require": {
        "tecnickcom/tcpdf": "6.11.*",
        "setasign/fpdi": "^2.6"
    }
}

If you want to use tFPDF, you have to update your composer.json to:

{
    "require": {
        "setasign/tfpdf": "1.33.*",
        "setasign/fpdi": "^2.6"
    }
}

Manual Installation

If you do not use composer, just require the autoload.php in the /src folder:

require_once('src/autoload.php');

If you have a PSR-4 autoloader implemented, just register the src path as follows:

$loader = new \Example\Psr4AutoloaderClass;
$loader->register();
$loader->addNamespace('setasign\Fpdi', 'path/to/src/');

Changes to Version 1

Version 2 is a complete rewrite from scratch of FPDI which comes with:

  • Namespaced code
  • Clean and up-to-date code base and style
  • PSR-4 compatible autoloading
  • Performance improvements by up to 100%
  • Less memory consumption
  • Native support for reading PDFs from strings or stream-resources
  • Support for documents with "invalid" data before their file-header
  • Optimized page tree resolving
  • Usage of individual exceptions
  • Several test types (unit, functional and visual tests)

We tried to keep the main methods and logical workflow the same as in version 1 but please notice that there were incompatible changes which you should consider when updating to version 2:

  • You need to load the code using the src/autoload.php file instead of classes/FPDI.php.
  • The classes and traits are namespaced now: setasign\Fpdi
  • Page boundaries beginning with a slash, such as /MediaBox, are not supported anymore. Remove the slash or use a constant of PdfReader\PageBoundaries.
  • The parameters $x, $y, $width and $height of the useTemplate() or getTemplateSize() method have more logical correct default values now. Passing 0 as width or height will result in an InvalidArgumentException now.
  • The return value of getTemplateSize() had changed to an array with more speaking keys and reusability: Use width instead of w and height instead of h.
  • If you want to use FPDI with TCPDF, you need to refactor your code to use the class Tcpdf\Fpdi (since 2.1; before it was TcpdfFpdi) instead of FPDI.

Example and Documentation

A simple example, that imports a single page and places this onto a new created page:

<?php
use setasign\Fpdi\Fpdi;
// or for usage with TCPDF:
// use setasign\Fpdi\Tcpdf\Fpdi;

// or for usage with tFPDF:
// use setasign\Fpdi\Tfpdf\Fpdi;

// setup the autoload function
require_once('vendor/autoload.php');

// initiate FPDI
$pdf = new Fpdi();
// add a page
$pdf->AddPage();
// set the source file
$pdf->setSourceFile("Fantastic-Speaker.pdf");
// import page 1
$tplId = $pdf->importPage(1);
// use the imported page and place it at point 10,10 with a width of 100 mm
$pdf->useTemplate($tplId, 10, 10, 100);

$pdf->Output();            

A full end-user documentation and API reference is available here.

setasign/fpdi 适用场景与选型建议

setasign/fpdi 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 154.27M 次下载、GitHub Stars 达 1.25k, 最近一次更新时间为 2012 年 12 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「pdf」 「fpdi」 「fpdf」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 setasign/fpdi 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 setasign/fpdi 我们能提供哪些服务?
定制开发 / 二次开发

基于 setasign/fpdi 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 154.27M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1280
  • 点击次数: 84
  • 依赖项目数: 246
  • 推荐数: 12

GitHub 信息

  • Stars: 1245
  • Watchers: 24
  • Forks: 181
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-12-06