sqkhor/publication-barcode

用于生成ISBN和ISSN条形码。

v1.0.2 2023-10-23 07:58 UTC

This package is auto-updated.

Last update: 2024-09-23 09:53:11 UTC


README

专门用于生成ISBN和ISSN条形码的PHP脚本。
它也可以生成其他EAN-13条形码,尽管不是为此而设计的。

安装

您可以选择将src/中的所有内容下载到您的项目中,或者通过composer安装

composer require sqkhor/publication-barcode

用法

use \SQKhor\Barcode\PublicationBarcode;

// ISBN
$barcode = new PublicationBarcode('978-967-2088-62-2');
$svg = $barcode->render('svg');

// ISBN with add on
$barcode = new PublicationBarcode('978-967-2088-62-2', '50999');
$png = $barcode->render('svg');

// ISSN with issue number
$barcode = new PublicationBarcode('3009-1004', '01');
$svg = $barcode->svg();

方法参数

new PublicationBarcode(code, [addon])

code (string)
13位ISBN / ISSN或8位ISSN代码

addon (?string)
用于价格(ISBN)和期号(ISSN)的补充条形码数据


render(format)

format (string)
以下之一:svg | png | jpg | jpeg

缩写

$barcode = new PublicationBarcode('978-967-2088-62-2');
$svg = $barcode->svg();
$png = $barcode->png();
$jpg = $barcode->jpg();

示例

ISBN

带期号的ISSN

待办事项

  • PNG / JPG渲染能力
  • 类参数设置条宽和高度
  • 每次使用后重置
  • 错误处理
  • 注释/文档
  • 测试