search
Homephp教程PHP源码PHP barcode generation package class

<?php
// 引用class文件夹对应的类
require_once(&#39;class/BCGFontFile.php&#39;);
require_once(&#39;class/BCGColor.php&#39;);
require_once(&#39;class/BCGDrawing.php&#39;);
  
// 条形码的编码格式
require_once(&#39;class/BCGcode39.barcode.php&#39;);
  
// 加载字体大小
$font = new BCGFontFile(&#39;./class/font/Arial.ttf&#39;, 18);
  
//颜色条形码
$color_black = new BCGColor(0, 0, 0);
$color_white = new BCGColor(255, 255, 255);
  
$drawException = null;
try {
    $code = new BCGcode39();
    $code->setScale(2); 
    $code->setThickness(30); // 条形码的厚度
    $code->setForegroundColor($color_black); // 条形码颜色
    $code->setBackgroundColor($color_white); // 空白间隙颜色
    $code->setFont($font); // 
    $code->parse(&#39;HELLO&#39;); // 条形码需要的数据内容
} catch(Exception $exception) {
    $drawException = $exception;
}
  
//根据以上条件绘制条形码
$drawing = new BCGDrawing(&#39;&#39;, $color_white);
if($drawException) {
    $drawing->drawException($drawException);
} else {
    $drawing->setBarcode($code);
    $drawing->draw();
}
  
// 生成PNG格式的图片
header(&#39;Content-Type: image/png&#39;);
  
  
$drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
?>

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software