mzur/invoiscript
Composer 安装命令:
composer require mzur/invoiscript
包简介
Generate simple PDF invoices
README 文档
README
Generate simple PDF invoices with PHP.
Installation
Run:
composer require mzur/invoiscript
Usage
Example
use Mzur\InvoiScript\Invoice; require_once(__DIR__.'/vendor/autoload.php'); $content = [ 'title' => 'Invoice No. 1', 'beforeInfo' => [ '<b>Date:</b>', 'June 10, 2021', ], 'afterInfo' => [ 'All prices in EUR.', '', 'This invoice is due on <b>June 20, 2021</b>.', ], 'clientAddress' => [ 'Jane Doe', 'Example Street 42', '1337 Demo City', ], 'entries' => [ [ 'description' => 'Hot air', 'quantity' => 11, 'price' => 8, ], [ 'description' => 'Something cool', 'quantity' => 5, 'price' => 20, ], ], ]; $pdf = new Invoice($content); $pdf->generate('invoice.pdf');
This generates the following PDF:
Styling
Content in title, beforeInfo and afterInfo can be styled with basic HTML-like tags. Example:
$content = [ 'title' => 'Invoice No. <b>1</b>', 'beforeInfo' => [ '<i>Date:</i>', '<u>June 10, 2021</u>', ], //... ];
Available tags:
<b></b>: Bold<i></i>: Italic<u></u>: Underlined
See the layout section for customization of font and font sizes.
Template
Set a template file:
$pdf = new Invoice($content); $pdf->setTemplate(__DIR__.'/template.pdf');
The template can have multiple pages, which will be used for the matching pages of the invoice. If the invoice has more pages than the template, the last page of the template will be repeated.
Language
Set the language:
$pdf = new Invoice($content); $pdf->setLanguage('de');
Available languages are en and de. Default is en.
Variables
Variables can be used in title, beforeInfo and afterInfo. Example:
$content = [ 'title' => 'Invoice No. {number}', 'beforeInfo' => [ '<b>Date:</b>', '{createdDate}', ], //... ]; $variables = [ 'number' => 1, 'createdDate' => 'June 10, 2021', ]; $pdf = new Invoice($content); $pdf->setVariables($variables);
The following variables are always available:
{total}: Total amount of the invoice.{page}: Current page number.{pages}: Total number of pages.
Layout
The default spacings, font, font size etc. can be overridden with a custom layout. Example:
$layout = [ 'font' => 'helvetica', ]; $pdf = new Invoice($content); $pdf->setLayout($layout);
See the source code for all available layout options and the defaults.
Acknowledgment
mzur/invoiscript 适用场景与选型建议
mzur/invoiscript 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 35 次下载、GitHub Stars 达 18, 最近一次更新时间为 2021 年 06 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mzur/invoiscript 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mzur/invoiscript 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 35
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-10
