Barcode
in package
Barcode generation class.
This class generates barcode images using the Barcode 128 encoding.
Tags
Table of Contents
- $font : string
- The font file path.
- $bar_width : int
- The width of each bar in the barcode (2D).
- $code : string
- The barcode code.
- $datas : array<string|int, mixed>
- The barcode data.
- $fontSize : int
- The font size of the label text (in pixels).
- $height : int
- The height of the barcode.
- $width : int
- The total width of the barcode.
- create() : static
- Create a Barcode instance.
- toPng() : string
- Generate a PNG image of the barcode.
- __construct() : mixed
- Class constructor.
- Barcode128() : mixed
- แปลงข้อมูล Barcode 128
Properties
$font
The font file path.
public
string
$font
= ROOT_PATH . 'skin/fonts/thsarabunnew-webfont.ttf'
$bar_width
The width of each bar in the barcode (2D).
private
int
$bar_width
= 1
$code
The barcode code.
private
string
$code
$datas
The barcode data.
private
array<string|int, mixed>
$datas
$fontSize
The font size of the label text (in pixels).
private
int
$fontSize
= 0
0 (default) means no label.
$height
The height of the barcode.
private
int
$height
$width
The total width of the barcode.
private
int
$width
= 0
Methods
create()
Create a Barcode instance.
public
static create(string $code[, int $height = 30 ], int $fontSize) : static
Parameters
- $code : string
-
The barcode code.
- $height : int = 30
-
The height of the barcode (in pixels). Default is 30.
- $fontSize : int
-
The font size of the label text (in pixels), 0 (default) means no label.
Return values
static —toPng()
Generate a PNG image of the barcode.
public
toPng() : string
Return values
string —The PNG image data.
__construct()
Class constructor.
protected
__construct(string $code, int $height, int $fontSize) : mixed
Parameters
- $code : string
-
The barcode code.
- $height : int
-
The height of the barcode (in pixels).
- $fontSize : int
-
The font size of the label text (in pixels), 0 (default) means no label.
Return values
mixed —Barcode128()
แปลงข้อมูล Barcode 128
private
static Barcode128( $code) : mixed