barcode-bakery/barcode-1d 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

barcode-bakery/barcode-1d

最新稳定版本:7.0.4

Composer 安装命令:

composer require barcode-bakery/barcode-1d

包简介

Generates 1D barcodes from a PHP server to a file or HTML document.

README 文档

README

Barcode Bakery is library written in PHP, .NET Standard and Node.JS which allows you to generate barcodes on the fly on your server for displaying or saving.

The library has minimal dependencies in each language in order to be supported on a wide variety of web servers.

The library is available for free for non-commercial use; however you must purchase a license if you plan to use it in a commercial environment.

Installation

There are two ways to install our library:

  • With composer, run the following command:
composer require barcode-bakery/barcode-1d

Requirements

  • PHP 7.4+ or PHP8
  • GD2

Example usages

For a full example of how to use each symbology type, visit our API page.

Displaying a Code 128 on the screen

<?php
// Path to the generated autoload file.
require __DIR__ . '/../vendor/autoload.php';

use BarcodeBakery\Common\BCGFontFile;
use BarcodeBakery\Common\BCGColor;
use BarcodeBakery\Common\BCGDrawing;
use BarcodeBakery\Barcode\BCGcode128;

$font = new BCGFontFile(__DIR__ . '/font/Arial.ttf', 18);
$colorBlack = new BCGColor(0, 0, 0);
$colorWhite = new BCGColor(255, 255, 255);

// Barcode Part
$code = new BCGcode128();
$code->setScale(2);
$code->setThickness(30);
$code->setForegroundColor($colorBlack);
$code->setBackgroundColor($colorWhite);
$code->setFont($font);
$code->setStart(null);
$code->setTilde(true);
$code->parse('a123');

// Drawing Part
$drawing = new BCGDrawing($code, $colorWhite);

header('Content-Type: image/png');
$drawing->finish(BCGDrawing::IMG_FORMAT_PNG);

Saving the image to a file

Replace the last lines of the previous code with the following:

// Drawing Part
$drawing = new BCGDrawing($code, $colorWhite);
$drawing->finish(BCGDrawing::IMG_FORMAT_PNG, 'path/to/file.png');

This will generate the following:

Supported types

Other libraries available for purchase

统计信息

  • 总下载量: 137.29k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 2
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 3
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2021-05-04