TCPDFBarcode
in package
Tags
Table of Contents
Properties
- $barcode_array : mixed
- Array representation of barcode.
Methods
- __construct() : mixed
- This is the class constructor.
- dec_to_hex() : string
- Convert large integer number to hexadecimal representation.
- getBarcodeArray() : array<string|int, mixed>
- Return an array representations of barcode.
- getBarcodeHTML() : string
- Return an HTML representation of barcode.
- getBarcodePNG() : mixed
- Send a PNG image representation of barcode (requires GD or Imagick library).
- getBarcodePngData() : string|Imagick|false
- Return a PNG image representation of barcode (requires GD or Imagick library).
- getBarcodeSVG() : mixed
- Send barcode as SVG image object to the standard output.
- getBarcodeSVGcode() : string
- Return a SVG string representation of barcode.
- hex_to_dec() : string
- Convert large hexadecimal number to decimal representation (string).
- setBarcode() : void
- Set the barcode.
- barcode_c128() : array<string|int, mixed>
- C128 barcodes.
- barcode_codabar() : array<string|int, mixed>
- CODABAR barcodes.
- barcode_code11() : array<string|int, mixed>
- CODE11 barcodes.
- barcode_code39() : array<string|int, mixed>
- CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
- barcode_code93() : array<string|int, mixed>
- CODE 93 - USS-93 Compact code similar to Code 39
- barcode_eanext() : array<string|int, mixed>
- UPC-Based Extensions 2-Digit Ext.: Used to indicate magazines and newspaper issue numbers 5-Digit Ext.: Used to mark suggested retail price of books
- barcode_eanupc() : array<string|int, mixed>
- EAN13 and UPC-A barcodes.
- barcode_i25() : array<string|int, mixed>
- Interleaved 2 of 5 barcodes.
- barcode_imb() : array<string|int, mixed>
- IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200 (requires PHP bcmath extension) Intelligent Mail barcode is a 65-bar code for use on mail in the United States.
- barcode_imb_pre() : array<string|int, mixed>
- IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
- barcode_msi() : array<string|int, mixed>
- MSI.
- barcode_pharmacode() : array<string|int, mixed>
- Pharmacode Contains digits (0 to 9)
- barcode_pharmacode2t() : array<string|int, mixed>
- Pharmacode two-track Contains digits (0 to 9)
- barcode_postnet() : array<string|int, mixed>
- POSTNET and PLANET barcodes.
- barcode_rms4cc() : array<string|int, mixed>
- RMS4CC - CBC - KIX RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code) - KIX (Klant index - Customer index) RM4SCC is the name of the barcode symbology used by the Royal Mail for its Cleanmail service.
- barcode_s25() : array<string|int, mixed>
- Standard 2 of 5 barcodes.
- binseq_to_array() : array<string|int, mixed>
- Convert binary barcode sequence to WarnockPDF barcode array.
- checksum_code39() : string
- Calculate CODE 39 checksum (modulo 43).
- checksum_code93() : string
- Calculate CODE 93 checksum (modulo 47).
- checksum_s25() : int
- Checksum for standard 2 of 5 barcodes.
- encode_code39_ext() : string
- Encode a string to be used for CODE 39 Extended mode.
- get128ABsequence() : array<string|int, mixed>
- Split text code in A/B sequence for 128 code
- imb_crc11fcs() : int
- Intelligent Mail Barcode calculation of Frame Check Sequence
- imb_reverse_us() : int
- Reverse unsigned short value
- imb_tables() : array<string|int, mixed>
- generate Nof13 tables used for Intelligent Mail Barcode
Properties
$barcode_array
Array representation of barcode.
protected
mixed
$barcode_array
= array()
Tags
Methods
__construct()
This is the class constructor.
public
__construct(string $code, string $type) : mixed
Return an array representations for common 1D barcodes:
- $arrcode['code'] code to be printed on text label
- $arrcode['maxh'] max barcode height
- $arrcode['maxw'] max barcode width
- $arrcode['bcode'][$k] single bar or space in $k position
- $arrcode['bcode'][$k]['t'] bar type: true = bar, false = space.
- $arrcode['bcode'][$k]['w'] bar width in units.
- $arrcode['bcode'][$k]['h'] bar height in units.
- $arrcode['bcode'][$k]['p'] bar top position (0 = top, 1 = middle)
Parameters
- $code : string
-
code to print
- $type : string
-
type of barcode:
- C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
- C39+ : CODE 39 with checksum
- C39E : CODE 39 EXTENDED
- C39E+ : CODE 39 EXTENDED + CHECKSUM
- C93 : CODE 93 - USS-93
- S25 : Standard 2 of 5
- S25+ : Standard 2 of 5 + CHECKSUM
- I25 : Interleaved 2 of 5
- I25+ : Interleaved 2 of 5 + CHECKSUM
- C128 : CODE 128
- C128A : CODE 128 A
- C128B : CODE 128 B
- C128C : CODE 128 C
- EAN2 : 2-Digits UPC-Based Extension
- EAN5 : 5-Digits UPC-Based Extension
- EAN8 : EAN 8
- EAN13 : EAN 13
- UPCA : UPC-A
- UPCE : UPC-E
- MSI : MSI (Variation of Plessey code)
- MSI+ : MSI + CHECKSUM (modulo 11)
- POSTNET : POSTNET
- PLANET : PLANET
- RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)
- KIX : KIX (Klant index - Customer index)
- IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200
- CODABAR : CODABAR
- CODE11 : CODE 11
- PHARMA : PHARMACODE
- PHARMA2T : PHARMACODE TWO-TRACKS
Tags
dec_to_hex()
Convert large integer number to hexadecimal representation.
public
dec_to_hex(string $number) : string
(requires PHP bcmath extension)
Parameters
- $number : string
-
number to convert specified as a string
Return values
string —hexadecimal representation
getBarcodeArray()
Return an array representations of barcode.
public
getBarcodeArray() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getBarcodeHTML()
Return an HTML representation of barcode.
public
getBarcodeHTML([int $w = 2 ][, int $h = 30 ][, string $color = 'black' ]) : string
Parameters
- $w : int = 2
-
Width of a single bar element in pixels.
- $h : int = 30
-
Height of a single bar element in pixels.
- $color : string = 'black'
-
Foreground color for bar elements (background is transparent).
Tags
Return values
string —HTML code.
getBarcodePNG()
Send a PNG image representation of barcode (requires GD or Imagick library).
public
getBarcodePNG([int $w = 2 ][, int $h = 30 ][, array<string|int, mixed> $color = array(0, 0, 0) ]) : mixed
Parameters
- $w : int = 2
-
Width of a single bar element in pixels.
- $h : int = 30
-
Height of a single bar element in pixels.
- $color : array<string|int, mixed> = array(0, 0, 0)
-
RGB (0-255) foreground color for bar elements (background is transparent).
Tags
getBarcodePngData()
Return a PNG image representation of barcode (requires GD or Imagick library).
public
getBarcodePngData([int $w = 2 ][, int $h = 30 ][, array<string|int, mixed> $color = array(0, 0, 0) ]) : string|Imagick|false
Parameters
- $w : int = 2
-
Width of a single bar element in pixels.
- $h : int = 30
-
Height of a single bar element in pixels.
- $color : array<string|int, mixed> = array(0, 0, 0)
-
RGB (0-255) foreground color for bar elements (background is transparent).
Tags
Return values
string|Imagick|false —image or false in case of error.
getBarcodeSVG()
Send barcode as SVG image object to the standard output.
public
getBarcodeSVG([int $w = 2 ][, int $h = 30 ][, string $color = 'black' ]) : mixed
Parameters
- $w : int = 2
-
Minimum width of a single bar in user units.
- $h : int = 30
-
Height of barcode in user units.
- $color : string = 'black'
-
Foreground color (in SVG format) for bar elements (background is transparent).
Tags
getBarcodeSVGcode()
Return a SVG string representation of barcode.
public
getBarcodeSVGcode([int $w = 2 ][, int $h = 30 ][, string $color = 'black' ]) : string
Parameters
- $w : int = 2
-
Minimum width of a single bar in user units.
- $h : int = 30
-
Height of barcode in user units.
- $color : string = 'black'
-
Foreground color (in SVG format) for bar elements (background is transparent).
Tags
Return values
string —SVG code.
hex_to_dec()
Convert large hexadecimal number to decimal representation (string).
public
hex_to_dec(string $hex) : string
(requires PHP bcmath extension)
Parameters
- $hex : string
-
hexadecimal number to convert specified as a string
Return values
string —hexadecimal representation
setBarcode()
Set the barcode.
public
setBarcode(string $code, string $type) : void
Parameters
- $code : string
-
code to print
- $type : string
-
type of barcode:
- C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
- C39+ : CODE 39 with checksum
- C39E : CODE 39 EXTENDED
- C39E+ : CODE 39 EXTENDED + CHECKSUM
- C93 : CODE 93 - USS-93
- S25 : Standard 2 of 5
- S25+ : Standard 2 of 5 + CHECKSUM
- I25 : Interleaved 2 of 5
- I25+ : Interleaved 2 of 5 + CHECKSUM
- C128 : CODE 128
- C128A : CODE 128 A
- C128B : CODE 128 B
- C128C : CODE 128 C
- EAN2 : 2-Digits UPC-Based Extension
- EAN5 : 5-Digits UPC-Based Extension
- EAN8 : EAN 8
- EAN13 : EAN 13
- UPCA : UPC-A
- UPCE : UPC-E
- MSI : MSI (Variation of Plessey code)
- MSI+ : MSI + CHECKSUM (modulo 11)
- POSTNET : POSTNET
- PLANET : PLANET
- RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)
- KIX : KIX (Klant index - Customer index)
- IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200
- IMBPRE: Pre-processed Intelligent Mail Barcode - Onecode - USPS-B-3200, using only F,A,D,T letters
- CODABAR : CODABAR
- CODE11 : CODE 11
- PHARMA : PHARMACODE
- PHARMA2T : PHARMACODE TWO-TRACKS
Tags
barcode_c128()
C128 barcodes.
protected
barcode_c128(string $code[, string $type = '' ]) : array<string|int, mixed>
Very capable code, excellent density, high reliability; in very wide use world-wide
Parameters
- $code : string
-
code to represent.
- $type : string = ''
-
barcode type: A, B, C or empty for automatic switch (AUTO mode)
Tags
Return values
array<string|int, mixed> —barcode representation.
barcode_codabar()
CODABAR barcodes.
protected
barcode_codabar(string $code) : array<string|int, mixed>
Older code often used in library systems, sometimes in blood banks
Parameters
- $code : string
-
code to represent.
Tags
Return values
array<string|int, mixed> —barcode representation.
barcode_code11()
CODE11 barcodes.
protected
barcode_code11(string $code) : array<string|int, mixed>
Used primarily for labeling telecommunications equipment
Parameters
- $code : string
-
code to represent.
Tags
Return values
array<string|int, mixed> —barcode representation.
barcode_code39()
CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
protected
barcode_code39(string $code[, bool $extended = false ][, bool $checksum = false ]) : array<string|int, mixed>
General-purpose code in very wide use world-wide
Parameters
- $code : string
-
code to represent.
- $extended : bool = false
-
if true uses the extended mode.
- $checksum : bool = false
-
if true add a checksum to the code.
Tags
Return values
array<string|int, mixed> —barcode representation.
barcode_code93()
CODE 93 - USS-93 Compact code similar to Code 39
protected
barcode_code93(string $code) : array<string|int, mixed>
Parameters
- $code : string
-
code to represent.
Tags
Return values
array<string|int, mixed> —barcode representation.
barcode_eanext()
UPC-Based Extensions 2-Digit Ext.: Used to indicate magazines and newspaper issue numbers 5-Digit Ext.: Used to mark suggested retail price of books
protected
barcode_eanext(string $code[, string $len = 5 ]) : array<string|int, mixed>
Parameters
- $code : string
-
code to represent.
- $len : string = 5
-
barcode type: 2 = 2-Digit, 5 = 5-Digit
Tags
Return values
array<string|int, mixed> —barcode representation.
barcode_eanupc()
EAN13 and UPC-A barcodes.
protected
barcode_eanupc(string $code[, string $len = 13 ]) : array<string|int, mixed>
EAN13: European Article Numbering international retail product code UPC-A: Universal product code seen on almost all retail products in the USA and Canada UPC-E: Short version of UPC symbol
Parameters
- $code : string
-
code to represent.
- $len : string = 13
-
barcode type: 6 = UPC-E, 8 = EAN8, 13 = EAN13, 12 = UPC-A
Tags
Return values
array<string|int, mixed> —barcode representation.
barcode_i25()
Interleaved 2 of 5 barcodes.
protected
barcode_i25(string $code[, bool $checksum = false ]) : array<string|int, mixed>
Compact numeric code, widely used in industry, air cargo Contains digits (0 to 9) and encodes the data in the width of both bars and spaces.
Parameters
- $code : string
-
code to represent.
- $checksum : bool = false
-
if true add a checksum to the code
Tags
Return values
array<string|int, mixed> —barcode representation.
barcode_imb()
IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200 (requires PHP bcmath extension) Intelligent Mail barcode is a 65-bar code for use on mail in the United States.
protected
barcode_imb(string $code) : array<string|int, mixed>
The fields are described as follows:
- The Barcode Identifier shall be assigned by USPS to encode the presort identification that is currently printed in human readable form on the optional endorsement line (OEL) as well as for future USPS use. This shall be two digits, with the second digit in the range of 0–4. The allowable encoding ranges shall be 00–04, 10–14, 20–24, 30–34, 40–44, 50–54, 60–64, 70–74, 80–84, and 90–94.
- The Service Type Identifier shall be assigned by USPS for any combination of services requested on the mailpiece. The allowable encoding range shall be 000http://it2.php.net/manual/en/function.dechex.php–999. Each 3-digit value shall correspond to a particular mail class with a particular combination of service(s). Each service program, such as OneCode Confirm and OneCode ACS, shall provide the list of Service Type Identifier values.
- The Mailer or Customer Identifier shall be assigned by USPS as a unique, 6 or 9 digit number that identifies a business entity. The allowable encoding range for the 6 digit Mailer ID shall be 000000- 899999, while the allowable encoding range for the 9 digit Mailer ID shall be 900000000-999999999.
- The Serial or Sequence Number shall be assigned by the mailer for uniquely identifying and tracking mailpieces. The allowable encoding range shall be 000000000–999999999 when used with a 6 digit Mailer ID and 000000-999999 when used with a 9 digit Mailer ID. e. The Delivery Point ZIP Code shall be assigned by the mailer for routing the mailpiece. This shall replace POSTNET for routing the mailpiece to its final delivery point. The length may be 0, 5, 9, or 11 digits. The allowable encoding ranges shall be no ZIP Code, 00000–99999, 000000000–999999999, and 00000000000–99999999999.
Parameters
- $code : string
-
code to print, separate the ZIP (routing code) from the rest using a minus char '-' (BarcodeID_ServiceTypeID_MailerID_SerialNumber-RoutingCode)
Tags
Return values
array<string|int, mixed> —barcode representation.
barcode_imb_pre()
IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
protected
barcode_imb_pre(string $code) : array<string|int, mixed>
Parameters
- $code : string
-
pre-formatted IMB barcode (65 chars "FADT")
Tags
Return values
array<string|int, mixed> —barcode representation.
barcode_msi()
MSI.
protected
barcode_msi(string $code[, bool $checksum = false ]) : array<string|int, mixed>
Variation of Plessey code, with similar applications Contains digits (0 to 9) and encodes the data only in the width of bars.
Parameters
- $code : string
-
code to represent.
- $checksum : bool = false
-
if true add a checksum to the code (modulo 11)
Tags
Return values
array<string|int, mixed> —barcode representation.
barcode_pharmacode()
Pharmacode Contains digits (0 to 9)
protected
barcode_pharmacode(string $code) : array<string|int, mixed>
Parameters
- $code : string
-
code to represent.
Tags
Return values
array<string|int, mixed> —barcode representation.
barcode_pharmacode2t()
Pharmacode two-track Contains digits (0 to 9)
protected
barcode_pharmacode2t(string $code) : array<string|int, mixed>
Parameters
- $code : string
-
code to represent.
Tags
Return values
array<string|int, mixed> —barcode representation.
barcode_postnet()
POSTNET and PLANET barcodes.
protected
barcode_postnet(string $code[, bool $planet = false ]) : array<string|int, mixed>
Used by U.S. Postal Service for automated mail sorting
Parameters
- $code : string
-
zip code to represent. Must be a string containing a zip code of the form DDDDD or DDDDD-DDDD.
- $planet : bool = false
-
if true print the PLANET barcode, otherwise print POSTNET
Tags
Return values
array<string|int, mixed> —barcode representation.
barcode_rms4cc()
RMS4CC - CBC - KIX RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code) - KIX (Klant index - Customer index) RM4SCC is the name of the barcode symbology used by the Royal Mail for its Cleanmail service.
protected
barcode_rms4cc(string $code[, bool $kix = false ]) : array<string|int, mixed>
Parameters
- $code : string
-
code to print
- $kix : bool = false
-
if true prints the KIX variation (doesn't use the start and end symbols, and the checksum) - in this case the house number must be sufficed with an X and placed at the end of the code.
Tags
Return values
array<string|int, mixed> —barcode representation.
barcode_s25()
Standard 2 of 5 barcodes.
protected
barcode_s25(string $code[, bool $checksum = false ]) : array<string|int, mixed>
Used in airline ticket marking, photofinishing Contains digits (0 to 9) and encodes the data only in the width of bars.
Parameters
- $code : string
-
code to represent.
- $checksum : bool = false
-
if true add a checksum to the code
Tags
Return values
array<string|int, mixed> —barcode representation.
binseq_to_array()
Convert binary barcode sequence to WarnockPDF barcode array.
protected
binseq_to_array(string $seq, array<string|int, mixed> $bararray) : array<string|int, mixed>
Parameters
- $seq : string
-
barcode as binary sequence.
- $bararray : array<string|int, mixed>
-
barcode array to fill up
Tags
Return values
array<string|int, mixed> —barcode representation.
checksum_code39()
Calculate CODE 39 checksum (modulo 43).
protected
checksum_code39(string $code) : string
Parameters
- $code : string
-
code to represent.
Tags
Return values
string —char checksum.
checksum_code93()
Calculate CODE 93 checksum (modulo 47).
protected
checksum_code93(string $code) : string
Parameters
- $code : string
-
code to represent.
Tags
Return values
string —checksum code.
checksum_s25()
Checksum for standard 2 of 5 barcodes.
protected
checksum_s25(string $code) : int
Parameters
- $code : string
-
code to process.
Tags
Return values
int —checksum.
encode_code39_ext()
Encode a string to be used for CODE 39 Extended mode.
protected
encode_code39_ext(string $code) : string
Parameters
- $code : string
-
code to represent.
Tags
Return values
string —encoded string.
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.
Tags
Return values
array<string|int, mixed> —sequence
imb_crc11fcs()
Intelligent Mail Barcode calculation of Frame Check Sequence
protected
imb_crc11fcs(string $code_arr) : int
Parameters
- $code_arr : string
-
array of hexadecimal values (13 bytes holding 102 bits right justified).
Tags
Return values
int —11 bit Frame Check Sequence as integer (decimal base)
imb_reverse_us()
Reverse unsigned short value
protected
imb_reverse_us(int $num) : int
Parameters
- $num : int
-
value to reversr
Tags
Return values
int —reversed value
imb_tables()
generate Nof13 tables used for Intelligent Mail Barcode
protected
imb_tables(int $n, int $size) : array<string|int, mixed>
Parameters
- $n : int
-
is the type of table: 2 for 2of13 table, 5 for 5of13table
- $size : int
-
size of table (78 for n=2 and 1287 for n=5)
Tags
Return values
array<string|int, mixed> —requested table