Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight;
CodeOneTwoEight Barcode type class CODE 128
Tags
Table of Contents
- $bars : array<string|int, mixed>
- Array containing the position and dimensions of each barcode bar (x, y, width, height)
- $bg_color_obj : Color
- Backgorund Color object
- $chbar : array<string|int, mixed>
- Map characters to barcodes
- $code : string
- Code to convert (barcode content)
- $color_obj : Color
- Foreground Color object
- $extcode : string
- Resulting code after applying checksum etc.
- $fnc_a : array<string|int, mixed>
- Map special FNC codes for Code Set A (FNC 1-4)
- $fnc_b : array<string|int, mixed>
- Map special FNC codes for Code Set B (FNC 1-4)
- $format : string
- Barcode format
- $height : float
- Barcode height
- $height_ratio : float
- Ratio between the barcode height and the number of columns
- $keys_a : array<string|int, mixed>
- Map ASCII characters for code A (ASCII 00 - 95)
- $keys_b : array<string|int, mixed>
- Map ASCII characters for code B (ASCII 32 - 127)
- $ncols : int
- Total number of columns
- $nrows : int
- Total number of rows
- $padding : array<string|int, mixed>
- Additional padding to add around the barcode (top, right, bottom, left) in user units.
- $params : array<string|int, mixed>
- Array containing extra parameters for the specified barcode type
- $type : string
- Barcode type (linear or square)
- $width : float
- Barcode width
- $width_ratio : float
- Ratio between the barcode width and the number of rows
- __construct() : mixed
- Initialize a new barcode object
- getArray() : array<string|int, mixed>
- Get the barcode raw array
- getBarsArray() : array<string|int, mixed>
- Get the array containing all the formatted bars coordinates
- getExtendedCode() : string
- Get the extended code (code + checksum)
- getGd() : object
- Get the barcode as GD image object (requires GD library)
- getGrid() : string
- Get a raw barcode string representation using characters
- getGridArray() : array<string|int, mixed>
- Get a raw barcode grid array
- getHtmlDiv() : string
- Get an HTML representation of the barcode.
- getPng() : mixed
- Get Barcode as PNG Image (requires GD or Imagick library)
- getPngData() : string
- Get the barcode as PNG image (requires GD or Imagick library)
- getPngDataImagick() : object
- Get the barcode as PNG image (requires Imagick library)
- getSvg() : mixed
- Get the barcode as SVG image object
- getSvgCode() : string
- Get the barcode as SVG code
- setBackgroundColor() : mixed
- Set the background color
- setColor() : mixed
- Set the color of the bars.
- setSize() : mixed
- Set the size of the barcode to be exported
- convertDecToHex() : string
- Convert large integer number to hexadecimal representation.
- convertHexToDec() : string
- Convert large hexadecimal number to decimal representation (string).
- finalizeCodeData() : array<string|int, mixed>
- Finalize code data
- get128ABsequence() : array<string|int, mixed>
- Split text code in A/B sequence for 128 code
- getBarRectXYWH() : array<string|int, mixed>
- Get the adjusted rectangular coordinates (x,y,w,h) for the specified bar
- getBarRectXYXY() : array<string|int, mixed>
- Get the adjusted rectangular coordinates (x1,y1,x2,y2) for the specified bar
- getCodeData() : mixed
- Get the coe point array
- getCodeDataA() : mixed
- Get the A code point array
- getCodeDataB() : mixed
- Get the B code point array
- getCodeDataC() : mixed
- Get the C code point array
- getNumericSequence() : array<string|int, mixed>
- Get the numeric sequence (if any)
- getRgbColorObject() : Color
- Get the RGB Color object for the given color representation
- getRotatedBarArray() : array<string|int, mixed>
- Returns the bars array ordered by columns
- processBinarySequence() : mixed
- Import a binary sequence of comma-separated 01 strings
- processSequenceA() : mixed
- Process the A sequence
- processSequenceB() : mixed
- Process the B sequence
- processSequenceBA() : mixed
- Process the B-A sequence
- processSequenceBB() : mixed
- Process the B-B sequence
- processSequenceC() : mixed
- Process the C sequence
- setAsciiMaps() : mixed
- Set the ASCII maps values
- setBars() : mixed
- Get the bars array
- setPadding() : mixed
- Set the barcode padding
- setParameters() : mixed
- Set extra (optional) parameters
Properties
$bars
Array containing the position and dimensions of each barcode bar (x, y, width, height)
protected array<string|int,
mixed> $bars = array()
$bg_color_obj
Backgorund Color object
protected Color $bg_color_obj
object
$chbar
Map characters to barcodes
protected array<string|int,
mixed> $chbar = array( '212222', // 00
'222122', // 01 '222221', // 02 '121223', // 03 '121322', // 04
'131222', // 05 '122213', // 06 '122312', // 07 '132212', // 08
'221213', // 09 '221312', // 10 '231212', // 11 '112232', // 12
'122132', // 13 '122231', // 14 '113222', // 15 '123122', // 16
'123221', // 17 '223211', // 18 '221132', // 19 '221231', // 20
'213212', // 21 '223112', // 22 '312131', // 23 '311222', // 24
'321122', // 25 '321221', // 26 '312212', // 27 '322112', // 28
'322211', // 29 '212123', // 30 '212321', // 31 '232121', // 32
'111323', // 33 '131123', // 34 '131321', // 35 '112313', // 36
'132113', // 37 '132311', // 38 '211313', // 39 '231113', // 40
'231311', // 41 '112133', // 42 '112331', // 43 '132131', // 44
'113123', // 45 '113321', // 46 '133121', // 47 '313121', // 48
'211331', // 49 '231131', // 50 '213113', // 51 '213311', // 52
'213131', // 53 '311123', // 54 '311321', // 55 '331121', // 56
'312113', // 57 '312311', // 58 '332111', // 59 '314111', // 60
'221411', // 61 '431111', // 62 '111224', // 63 '111422', // 64
'121124', // 65 '121421', // 66 '141122', // 67 '141221', // 68
'112214', // 69 '112412', // 70 '122114', // 71 '122411', // 72
'142112', // 73 '142211', // 74 '241211', // 75 '221114', // 76
'413111', // 77 '241112', // 78 '134111', // 79 '111242', // 80
'121142', // 81 '121241', // 82 '114212', // 83 '124112', // 84
'124211', // 85 '411212', // 86 '421112', // 87 '421211', // 88
'212141', // 89 '214121', // 90 '412121', // 91 '111143', // 92
'111341', // 93 '131141', // 94 '114113', // 95 '114311', // 96
'411113', // 97 '411311', // 98 '113141', // 99 '114131', // 100
'311141', // 101 '411131', // 102 '211412', // 103 START A
'211214', // 104 START B '211232', // 105 START C '233111', // STOP
'200000', )
$code
Code to convert (barcode content)
protected string $code = ''
$color_obj
Foreground Color object
protected Color $color_obj
object
$extcode
Resulting code after applying checksum etc.
protected string $extcode = ''
$fnc_a
Map special FNC codes for Code Set A (FNC 1-4)
protected array<string|int,
mixed> $fnc_a = array(241 => 102, 242
=> 97, 243 => 96, 244 => 101)
$fnc_b
Map special FNC codes for Code Set B (FNC 1-4)
protected array<string|int,
mixed> $fnc_b = array(241 => 102, 242
=> 97, 243 => 96, 244 => 100)
$format
Barcode format
protected string $format = 'C128'
$height
Barcode height
protected float $height
$height_ratio
Ratio between the barcode height and the number of columns
protected float $height_ratio
$keys_a
Map ASCII characters for code A (ASCII 00 - 95)
protected array<string|int,
mixed> $keys_a = ''
$keys_b
Map ASCII characters for code B (ASCII 32 - 127)
protected array<string|int,
mixed> $keys_b = ''
$ncols
Total number of columns
protected int $ncols = 0
$nrows
Total number of rows
protected int $nrows = 1
$padding
Additional padding to add around the barcode (top, right, bottom, left) in user units.
protected array<string|int,
mixed> $padding = array('T' => 0, 'R'
=> 0, 'B' => 0, 'L' => 0)
A negative value indicates the multiplication factor for each row or column.
$params
Array containing extra parameters for the specified barcode type
protected array<string|int,
mixed> $params
$type
Barcode type (linear or square)
protected string $type = ''
$width
Barcode width
protected float $width
$width_ratio
Ratio between the barcode width and the number of rows
protected float $width_ratio
Methods
__construct()
Initialize a new barcode object
public __construct(string $code[,
int $width
= -1
][,
int $height
= -1
][,
string $color
= 'black'
][,
array<string|int,
mixed> $params
= array()
][,
array<string|int,
mixed> $padding
= array(0, 0, 0,
0) ]) :
mixed
Parameters
- $code : string
-
Barcode content
- $width : int = -1
-
Barcode width in user units (excluding padding). A negative value indicates the multiplication factor for each column.
- $height : int = -1
-
Barcode height in user units (excluding padding). A negative value indicates the multiplication factor for each row.
- $color : string = 'black'
-
Foreground color in Web notation (color name, or hexadecimal code, or CSS syntax)
- $params : array<string|int, mixed> = array()
-
Array containing extra parameters for the specified barcode type
- $padding : array<string|int, mixed> = array(0, 0, 0, 0)
-
Additional padding to add around the barcode (top, right, bottom, left) in user units. A negative value indicates the number or rows or columns.
Tags
Return values
mixed —getArray()
Get the barcode raw array
public getArray()
: array<string|int,
mixed>
Return values
array<string|int, mixed> —getBarsArray()
Get the array containing all the formatted bars coordinates
public getBarsArray([string $type
= 'XYXY'
]) : array<string|int,
mixed>
Parameters
- $type : string = 'XYXY'
-
Type of coordinates to return: 'XYXY' or 'XYWH'
Return values
array<string|int, mixed> —getExtendedCode()
Get the extended code (code + checksum)
public getExtendedCode()
: string
Return values
string —getGd()
Get the barcode as GD image object (requires GD library)
public getGd()
: object
Tags
Return values
object —getGrid()
Get a raw barcode string representation using characters
public getGrid([string $space_char
= '0'
][,
string $bar_char
= '1'
]) : string
Parameters
- $space_char : string = '0'
-
Character or string to use for filling empty spaces
- $bar_char : string = '1'
-
Character or string to use for filling bars
Return values
string —getGridArray()
Get a raw barcode grid array
public getGridArray([string $space_char
= '0'
][,
string $bar_char
= '1'
]) : array<string|int,
mixed>
Parameters
- $space_char : string = '0'
-
Character or string to use for filling empty spaces
- $bar_char : string = '1'
-
Character or string to use for filling bars
Return values
array<string|int, mixed> —getHtmlDiv()
Get an HTML representation of the barcode.
public getHtmlDiv()
: string
Return values
string —HTML code (DIV block)
getPng()
Get Barcode as PNG Image (requires GD or Imagick library)
public getPng()
: mixed
Return values
mixed —getPngData()
Get the barcode as PNG image (requires GD or Imagick library)
public getPngData([bool $imagick
= true
]) : string
Parameters
- $imagick : bool = true
-
If true try to use the Imagick extension
Return values
string —PNG image data
getPngDataImagick()
Get the barcode as PNG image (requires Imagick library)
public getPngDataImagick()
: object
Tags
Return values
object —getSvg()
Get the barcode as SVG image object
public getSvg()
: mixed
Return values
mixed —getSvgCode()
Get the barcode as SVG code
public getSvgCode()
: string
Return values
string —SVG code
setBackgroundColor()
Set the background color
public setBackgroundColor(string $color)
: mixed
Parameters
- $color : string
-
Background color in Web notation (color name, or hexadecimal code, or CSS syntax)
Tags
Return values
mixed —setColor()
Set the color of the bars.
public setColor(string $color)
: mixed
If the color is transparent or empty it will be set to the default black color.
Parameters
- $color : string
-
Foreground color in Web notation (color name, or hexadecimal code, or CSS syntax)
Tags
Return values
mixed —setSize()
Set the size of the barcode to be exported
public setSize(int $width,
int $height[,
array<string|int,
mixed> $padding
= array(0, 0, 0,
0) ]) :
mixed
Parameters
- $width : int
-
Barcode width in user units (excluding padding). A negative value indicates the multiplication factor for each column.
- $height : int
-
Barcode height in user units (excluding padding). A negative value indicates the multiplication factor for each row.
- $padding : array<string|int, mixed> = array(0, 0, 0, 0)
-
Additional padding to add around the barcode (top, right, bottom, left) in user units. A negative value indicates the number or rows or columns.
Return values
mixed —convertDecToHex()
Convert large integer number to hexadecimal representation.
protected convertDecToHex(string $number)
: string
Parameters
- $number : string
-
Number to convert (as string)
Return values
string —hexadecimal representation
convertHexToDec()
Convert large hexadecimal number to decimal representation (string).
protected convertHexToDec(string $hex)
: string
Parameters
- $hex : string
-
Hexadecimal number to convert (as string)
Return values
string —hexadecimal representation
finalizeCodeData()
Finalize code data
protected finalizeCodeData(array<string|int,
mixed> $code_data,
int $startid)
: array<string|int,
mixed>
Parameters
- $code_data : array<string|int, mixed>
-
Array of codepoints to alter
- $startid : int
-
Start ID code
Return values
array<string|int, mixed> —get128ABsequence()
Split text code in A/B sequence for 128 code
protected get128ABsequence(string $code)
: array<string|int,
mixed>
Parameters
- $code : string
-
Code to split
Return values
array<string|int, mixed> —sequence
getBarRectXYWH()
Get the adjusted rectangular coordinates (x,y,w,h) for the specified bar
protected getBarRectXYWH(mixed $bar)
: array<string|int,
mixed>
Parameters
- $bar : mixed
Return values
array<string|int, mixed> —Bar coordinates
getBarRectXYXY()
Get the adjusted rectangular coordinates (x1,y1,x2,y2) for the specified bar
protected getBarRectXYXY(mixed $bar)
: array<string|int,
mixed>
Parameters
- $bar : mixed
Return values
array<string|int, mixed> —Bar coordinates
getCodeData()
Get the coe point array
protected getCodeData()
: mixed
Tags
Return values
mixed —getCodeDataA()
Get the A code point array
protected getCodeDataA(array<string|int,
mixed> &$code_data,
string $code,
int $len)
: mixed
Parameters
- $code_data : array<string|int, mixed>
-
Array of codepoints to alter
- $code : string
-
Code to process
- $len : int
-
Number of characters to process
Tags
Return values
mixed —getCodeDataB()
Get the B code point array
protected getCodeDataB(array<string|int,
mixed> &$code_data,
string $code,
int $len)
: mixed
Parameters
- $code_data : array<string|int, mixed>
-
Array of codepoints to alter
- $code : string
-
Code to process
- $len : int
-
Number of characters to process
Tags
Return values
mixed —getCodeDataC()
Get the C code point array
protected getCodeDataC(array<string|int,
mixed> &$code_data,
string $code)
: mixed
Parameters
- $code_data : array<string|int, mixed>
-
Array of codepoints to alter
- $code : string
-
Code to process
Tags
Return values
mixed —getNumericSequence()
Get the numeric sequence (if any)
protected getNumericSequence(string $code)
: array<string|int,
mixed>
Parameters
- $code : string
-
Code to parse
Tags
Return values
array<string|int, mixed> —getRgbColorObject()
Get the RGB Color object for the given color representation
protected getRgbColorObject(string $color)
: Color
Parameters
- $color : string
-
Color in Web notation (color name, or hexadecimal code, or CSS syntax)
Tags
Return values
Color —object or null
getRotatedBarArray()
Returns the bars array ordered by columns
protected getRotatedBarArray()
: array<string|int,
mixed>
Return values
array<string|int, mixed> —processBinarySequence()
Import a binary sequence of comma-separated 01 strings
protected processBinarySequence(string $code)
: mixed
Parameters
- $code : string
-
Code to process
Return values
mixed —processSequenceA()
Process the A sequence
protected processSequenceA(array<string|int,
mixed> &$sequence,
array<string|int,
mixed> &$code_data,
int &$startid,
int $key,
string $seq)
: mixed
Parameters
- $sequence : array<string|int, mixed>
-
Sequence to process
- $code_data : array<string|int, mixed>
-
Array of codepoints to alter
- $startid : int
-
Start ID
- $key : int
-
Sequence current key
- $seq : string
-
Sequence current value
Tags
Return values
mixed —processSequenceB()
Process the B sequence
protected processSequenceB(array<string|int,
mixed> &$sequence,
array<string|int,
mixed> &$code_data,
int &$startid,
int $key,
string $seq)
: mixed
Parameters
- $sequence : array<string|int, mixed>
-
Sequence to process
- $code_data : array<string|int, mixed>
-
Array of codepoints to alter
- $startid : int
-
Start ID
- $key : int
-
Sequence current key
- $seq : string
-
Sequence current value
Tags
Return values
mixed —processSequenceBA()
Process the B-A sequence
protected processSequenceBA(array<string|int,
mixed> &$sequence,
array<string|int,
mixed> &$code_data,
int &$startid,
int $key,
string $seq)
: mixed
Parameters
- $sequence : array<string|int, mixed>
-
Sequence to process
- $code_data : array<string|int, mixed>
-
Array of codepoints to alter
- $startid : int
-
Start ID
- $key : int
-
Sequence current key
- $seq : string
-
Sequence current value
Tags
Return values
mixed —processSequenceBB()
Process the B-B sequence
protected processSequenceBB(array<string|int,
mixed> &$sequence,
array<string|int,
mixed> &$code_data,
int $key,
string $seq)
: mixed
Parameters
- $sequence : array<string|int, mixed>
-
Sequence to process
- $code_data : array<string|int, mixed>
-
Array of codepoints to alter
- $key : int
-
Sequence current key
- $seq : string
-
Sequence current value
Tags
Return values
mixed —processSequenceC()
Process the C sequence
protected processSequenceC(array<string|int,
mixed> &$sequence,
array<string|int,
mixed> &$code_data,
int &$startid,
int $key,
string $seq)
: mixed
Parameters
- $sequence : array<string|int, mixed>
-
Sequence to process
- $code_data : array<string|int, mixed>
-
Array of codepoints to alter
- $startid : int
-
Start ID
- $key : int
-
Sequence current key
- $seq : string
-
Sequence current value
Tags
Return values
mixed —setAsciiMaps()
Set the ASCII maps values
protected setAsciiMaps()
: mixed
Return values
mixed —setBars()
Get the bars array
protected setBars()
: mixed
Tags
Return values
mixed —setPadding()
Set the barcode padding
protected setPadding(array<string|int,
mixed> $padding)
: mixed
Parameters
- $padding : array<string|int, mixed>
-
Additional padding to add around the barcode (top, right, bottom, left) in user units. A negative value indicates the number or rows or columns.
Tags
Return values
mixed —setParameters()
Set extra (optional) parameters
protected setParameters()
: mixed