diecoding/yii2-barcode-generator

Yii2的JavaScript条码生成器

v1.0.2 2023-04-28 03:24 UTC

This package is auto-updated.

Last update: 2024-09-06 07:30:24 UTC


README

Yii2的JavaScript条码生成器

Latest Stable Version Total Downloads Latest Stable Release Date Quality Score Build Status License PHP Version Require

Yii2 Barcode Generator使用JsBarcode
演示:https://lindell.me/JsBarcode/

目录

安装

该包可在Packagist上找到,您可以使用Composer进行安装。

composer require diecoding/yii2-barcode-generator "^1.0"

或将其添加到您的composer.json文件的require部分。

"diecoding/yii2-barcode-generator": "^1.0"

依赖

使用方法

https://github.com/lindell/JsBarcode/wiki#barcodes上作为JavaScript代码的Wiki

简单使用

use diecoding\barcode\generator\Barcode;

// CODE128 (auto) is the default mode
Barcode::widget([
  'value' => 'Hi world!',
]);

// CODE128
Barcode::widget([
  'value'  => 'Example1234',
  'format' => Barcode::CODE128
]);

// CODE128A
Barcode::widget([
  'value'  => 'EXAMPLE\n1234',
  'format' => Barcode::CODE128A
]);

// ...

高级使用

use diecoding\barcode\generator\Barcode;

Barcode::widget([
  'value'         => '1234',
  'format'        => Barcode::PHARMACODE,
  'pluginOptions' => [
    'lineColor'    => '#0aa',
    'width'        => 4,
    'height'       => 40,
    'displayValue' => false
  ]
]);

// Enable encoding CODE128 as GS1-128/EAN-128.
Barcode::widget([
  'value'         => '12345678',
  'format'        => Barcode::CODE128C,
  'pluginOptions' => [
    'ean128' => true,
  ]
]);

// Change Element Tag, default svg, available svg, img, canvas
Barcode::widget([
  'tag'           => 'img',
  'value'         => '12345678',
  'format'        => Barcode::CODE128C,
  'pluginOptions' => [
    'ean128' => true,
  ]
]);

// Change Element Tag, add custom style element tag, hide value text
Barcode::widget([
  'tag'     => 'img',
  'value'   => '12345678',
  'options' => [
      'style' => "width: 4cm; height: 1cm;",
  ],
  'pluginOptions' => [
      'displayValue' => false,
  ],
]);

// ...

阅读更多文档:https://sugengsulistiyawan.my.id/docs/opensource/yii2/barcode-generator/