定制 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!

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固