PHP barcode generation package class
Release: 2016-07-25 08:42:18
Original
1066 people have browsed it
- // Reference the class corresponding to the class folder
- require_once('class/BCGFontFile.php');
- require_once('class/BCGColor.php');
- require_once('class/BCGDrawing. php');
-
- // Barcode encoding format
- require_once('class/BCGcode39.barcode.php');
-
- // Load font size
- $font = new BCGFontFile('./class/font/Arial.ttf ', 18);
-
- //Color barcode
- $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); // Barcode thickness
- $code->setForegroundColor($color_black); // Barcode Color
- $code->setBackgroundColor($color_white); // Blank gap color
- $code->setFont($font); //
- $code->parse('HELLO'); // Required for barcode Data content
- } catch(Exception $exception) {
- $drawException = $exception;
- }
-
- //Draw the barcode according to the above conditions
- $drawing = new BCGDrawing('', $color_white);
- if($drawException) {
- $drawing->drawException($drawException);
- } else {
- $drawing->setBarcode($code);
- $drawing->draw();
- }
-
- // Generate pictures in PNG format
- header('Content-Type: image/png');
-
-
- $drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
- ?>
Copy code
|
PHP
Statement of this Website
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
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31