Constants

SIZE_SPACING_FONT

SIZE_SPACING_FONT = 5

AUTO_LABEL

AUTO_LABEL = '##!!AUTO_LABEL!!##'

COLOR_BG

COLOR_BG = 0

COLOR_FG

COLOR_FG = 1

Properties

$thickness

$thickness : 

Type

$keys

$keys : 

Type

$code

$code : 

Type

$positionX

$positionX : 

Type

$font

$font : 

Type

$text

$text : 

Type

$checksumValue

$checksumValue : 

Type

$displayChecksum

$displayChecksum : 

Type

$label

$label : 

Type

$defaultLabel

$defaultLabel : 

Type

$colorFg

$colorFg : 

Type

$colorBg

$colorBg : 

Type

$scale

$scale : 

Type

$offsetX

$offsetX : 

Type

$offsetY

$offsetY : 

Type

$labels

$labels : 

Type

$pushLabel

$pushLabel : 

Type

$barcodeIdentifier

$barcodeIdentifier : 

Type

$serviceTypeIdentifier

$serviceTypeIdentifier : 

Type

$mailerIdentifier

$mailerIdentifier : 

Type

$serialNumber

$serialNumber : 

Type

$quietZone

$quietZone : 

Type

$data

$data : 

Type

$characterTable1

$characterTable1 : 

Type

$characterTable2

$characterTable2 : 

Type

$barPositions

$barPositions : 

Type

Methods

__construct()

__construct() 

Constructor.

getThickness()

getThickness() : integer

Gets the thickness.

Returns

integer

setThickness()

setThickness(integer  $thickness) 

Sets the thickness.

Parameters

integer $thickness

getLabel()

getLabel() : string

Gets the label.

If the label was set to BCGBarcode1D::AUTO_LABEL, the label will display the value from the text parsed.

Returns

string

setLabel()

setLabel(string  $label) 

Sets the label.

You can use BCGBarcode::AUTO_LABEL to have the label automatically written based on the parsed text.

Parameters

string $label

getFont()

getFont() : \BCGFont

Gets the font.

Returns

\BCGFont

setFont()

setFont(mixed  $font) 

Sets the font.

Parameters

mixed $font

BCGFont or int

parse()

parse(mixed  $text) 

Parses the text before displaying it.

Parameters

mixed $text

getChecksum()

getChecksum() : string

Gets the checksum of a Barcode.

If no checksum is available, return FALSE.

Returns

string

setDisplayChecksum()

setDisplayChecksum(boolean  $displayChecksum) 

Sets if the checksum is displayed with the label or not.

The checksum must be activated in some case to make this variable effective.

Parameters

boolean $displayChecksum

getForegroundColor()

getForegroundColor() : \BCGColor

Gets the foreground color of the barcode.

Returns

\BCGColor

setForegroundColor()

setForegroundColor(mixed  $code) 

Sets the foreground color of the barcode. It could be a BCGColor value or simply a language code (white, black, yellow.

..) or hex value.

Parameters

mixed $code

getBackgroundColor()

getBackgroundColor() : \BCGColor

Gets the background color of the barcode.

Returns

\BCGColor

setBackgroundColor()

setBackgroundColor(mixed  $code) 

Sets the background color of the barcode. It could be a BCGColor value or simply a language code (white, black, yellow.

..) or hex value.

Parameters

mixed $code

setColor()

setColor(mixed  $fg, mixed  $bg) 

Sets the color.

Parameters

mixed $fg
mixed $bg

getScale()

getScale() : integer

Gets the scale of the barcode.

Returns

integer

setScale()

setScale(integer  $scale) 

Sets the scale of the barcode in pixel.

If the scale is lower than 1, an exception is raised.

Parameters

integer $scale

draw()

draw(resource  $im) 

Draws the barcode.

Parameters

resource $im

getDimension()

getDimension(integer  $w, integer  $h) : array<mixed,integer>

Returns the maximal size of a barcode.

Parameters

integer $w
integer $h

Returns

array<mixed,integer>

getOffsetX()

getOffsetX() : integer

Gets the X offset.

Returns

integer

setOffsetX()

setOffsetX(integer  $offsetX) 

Sets the X offset.

Parameters

integer $offsetX

getOffsetY()

getOffsetY() : integer

Gets the Y offset.

Returns

integer

setOffsetY()

setOffsetY(integer  $offsetY) 

Sets the Y offset.

Parameters

integer $offsetY

addLabel()

addLabel(\BCGLabel  $label) 

Adds the label to the drawing.

Parameters

\BCGLabel $label

removeLabel()

removeLabel(\BCGLabel  $label) 

Removes the label from the drawing.

Parameters

\BCGLabel $label

clearLabels()

clearLabels() 

Clears the labels.

getQuietZone()

getQuietZone() : boolean

Gets the Quiet zone.

Returns

boolean

setQuietZone()

setQuietZone(boolean  $quietZone) 

Sets the Quiet zone.

Parameters

boolean $quietZone

setTrackingCode()

setTrackingCode(integer  $barcodeIdentifier, integer  $serviceTypeIdentifier, integer  $mailerIdentifier, integer  $serialNumber) 

Sets the tracking code.

Parameters

integer $barcodeIdentifier

2-digit number. 2nd digit must be 0-4

integer $serviceTypeIdentifier

3 digits

integer $mailerIdentifier

6 or 9 digits

integer $serialNumber

9 (if mailerId is 6) or 6 digits (if mailerId is 9)

addDefaultLabel()

addDefaultLabel() 

Adds the default label.

validate()

validate() 

Validates the input.

findIndex()

findIndex(mixed  $var) : mixed

Returns the index in $keys (useful for checksum).

Parameters

mixed $var

Returns

mixed

findCode()

findCode(mixed  $var) : string

Returns the code of the char (useful for drawing bars).

Parameters

mixed $var

Returns

string

drawChar()

drawChar(resource  $im, string  $code, boolean  $startBar = true) 

Overloaded method for drawing special barcode.

If $startBar is false, the line begins by a bar.

Parameters

resource $im
string $code
boolean $startBar

drawSingleBar()

drawSingleBar(  $im, integer  $color) 

Draws a Bar of $color depending of the resolution.

Parameters

$im
integer $color

nextX()

nextX() 

Moving the pointer right to write a bar.

calculateChecksum()

calculateChecksum() 

Method that saves FALSE into the checksumValue. This means no checksum but this method should be overriden when needed.

processChecksum()

processChecksum() : string

Returns FALSE because there is no checksum. This method should be overriden to return correctly the checksum in string with checksumValue.

Returns

string

drawText()

drawText(resource  $im, integer  $x1, integer  $y1, integer  $x2, integer  $y2) 

Draws the text.

The coordinate passed are the positions of the barcode. $x1 and $y1 represent the top left corner. $x2 and $y2 represent the bottom right corner.

Parameters

resource $im
integer $x1
integer $y1
integer $x2
integer $y2

drawPixel()

drawPixel(resource  $im, integer  $x, integer  $y, integer  $color = self::COLOR_FG) 

Draws 1 pixel on the resource at a specific position with a determined color.

Parameters

resource $im
integer $x
integer $y
integer $color

drawRectangle()

drawRectangle(resource  $im, integer  $x1, integer  $y1, integer  $x2, integer  $y2, integer  $color = self::COLOR_FG) 

Draws an empty rectangle on the resource at a specific position with a determined color.

Parameters

resource $im
integer $x1
integer $y1
integer $x2
integer $y2
integer $color

drawFilledRectangle()

drawFilledRectangle(resource  $im, integer  $x1, integer  $y1, integer  $x2, integer  $y2, integer  $color = self::COLOR_FG) 

Draws a filled rectangle on the resource at a specific position with a determined color.

Parameters

resource $im
integer $x1
integer $y1
integer $x2
integer $y2
integer $color

getColor()

getColor(resource  $im, integer  $color) : resource

Allocates the color based on the integer.

Parameters

resource $im
integer $color

Returns

resource

getBiggestLabels()

getBiggestLabels(boolean  $reversed = false) : array<mixed,\BCGLabel>

Returning the biggest label widths for LEFT/RIGHT and heights for TOP/BOTTOM.

Parameters

boolean $reversed

Returns

array<mixed,\BCGLabel>

executeStep1()

executeStep1(string  $text, string  $barcodeIdentifier, string  $serviceTypeIdentifier, string  $mailerIdentifier, string  $serialNumber) : string

Executes Step 1: Conversion of Data Fields into Binary Data

Parameters

string $text
string $barcodeIdentifier
string $serviceTypeIdentifier
string $mailerIdentifier
string $serialNumber

Returns

string —

BCNumber

executeStep2()

executeStep2(  $number) : integer

Executes Step 2: Generation of 11-Bit CRC on Binary Data

Parameters

$number

BCNumber

Returns

integer

executeStep3()

executeStep3(string  $number) : array<mixed,integer>

Executes Step 3: Conversion from Binary Data to Codewords

Parameters

string $number

BCNumber

Returns

array<mixed,integer>

executeStep4()

executeStep4(array<mixed,integer>  $codewords, integer  $crc) : array<mixed,integer>

Executes Step 4: Inserting Additional Information into Codewords

Parameters

array<mixed,integer> $codewords
integer $crc

Returns

array<mixed,integer>

executeStep5()

executeStep5(array<mixed,integer>  $codewords, integer  $crc) : array<mixed,integer>

Executes Step 5: Conversion from Codewords to Characters

Parameters

array<mixed,integer> $codewords
integer $crc

Returns

array<mixed,integer>

executeStep6()

executeStep6(array<mixed,integer>  $characters) : string

Executes Step 6: Conversion from Characters to the Intelligent Mail Barcode

Parameters

array<mixed,integer> $characters

Returns

string

conversionRoutingCode()

conversionRoutingCode(string  $zipcode) : string

Converts the routing code zipcode.

Parameters

string $zipcode

Returns

string —

BCNumber

conversionTrackingCode()

conversionTrackingCode(string  $number, string  $barcodeIdentifier, string  $serviceTypeIdentifier, string  $mailerIdentifier, string  $serialNumber) : string

Converts the tracking code number.

Parameters

string $number

BCNumber

string $barcodeIdentifier
string $serviceTypeIdentifier
string $mailerIdentifier
string $serialNumber

Returns

string —

BCNumber

bcdecuc()

bcdecuc(string  $dec) 

Transforms a BCNumber into unsigned char*.

Parameters

string $dec

BCNumber