famoser/pdf-generator
Composer 安装命令:
composer require famoser/pdf-generator
包简介
a clean pdf generator without dependencies
README 文档
README
About
Generates pdf files without any dependencies. Includes a layout engine to handle flow content (e.g. text spanning over more than one page).
composer require famoser/pdf-generator
This is still under active development (contributions welcome!), and the public API is subject to change. If you are looking for a more mature project, see https://github.com/tecnickcom/TCPDF.
Getting started
Using the printer:
// places "Hello world" in the top-left corner of the document. $document = new Document(); $printer = $document->createPrinter(); $bodyText = new TextStyle(Font::createFromDefault()); $printer->printText('Hello world', $bodyText); file_put_contents('example.pdf', $document->save());
The printer is useful when the exact position of elements is known. For example, for correspondence with fixed layout (e.g. the address in a letter) or for documents with page numbers. However, for many elements (such as tables) determining the exact position is cumbersome. For this, layouts are provided.
Using layouts:
// adds a rectangle, followed by "Hello moon". // placement is decided by Flow, which places elements one-after-the-other. $flow = new Flow(); $rectangle = new Rectangle(width: 120, height: 80, style: new DrawingStyle()); $flow->addContent($rectangle); $text = new Text(); $text->addSpan('Hello moon', $bodyText); $flow->add($text); $document->add($flow); file_put_contents('example.pdf', $document->save());
The layouts allow to declare what needs to be printed, and then takes care of the where. Provided are flows, grids, tables and text.
Examples
Invoice
![]() |
Book
![]() |
![]() |
![]() |
![]() |
famoser/pdf-generator 适用场景与选型建议
famoser/pdf-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.53k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2019 年 01 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 famoser/pdf-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 famoser/pdf-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.53k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-28




