定制 mzur/invoiscript 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

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

Thanks to the creator(s) of FPDF and FPDI!

mzur/invoiscript 适用场景与选型建议

mzur/invoiscript 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 35 次下载、GitHub Stars 达 18, 最近一次更新时间为 2021 年 06 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 35
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 18
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 18
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-06-10