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

$keys

$keys

$code

$code

$positionX

$positionX

$font

$font

$text

$text

$checksumValue

$checksumValue

$displayChecksum

$displayChecksum

$label

$label

$defaultLabel

$defaultLabel

$colorFg

$colorFg

$colorBg

$colorBg

$scale

$scale

$offsetX

$offsetX

$offsetY

$offsetY

$labels

$labels

$pushLabel

$pushLabel

$barcodeIdentifier

$barcodeIdentifier

$serviceTypeIdentifier

$serviceTypeIdentifier

$mailerIdentifier

$mailerIdentifier

$serialNumber

$serialNumber

$quietZone

$quietZone

$data

$data

$characterTable1

$characterTable1

$characterTable2

$characterTable2

$barPositions

$barPositions

Methods

__construct()

__construct() : mixed

Constructor.

Returns

mixed —

getThickness()

getThickness() : int

Gets the thickness.

Returns

int —

setThickness()

setThickness(int  $thickness) : mixed

Sets the thickness.

Parameters

int $thickness

Returns

mixed —

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) : mixed

Sets the label.

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

Parameters

string $label

Returns

mixed —

getFont()

getFont() : \BarcodeBakery\Common\BCGFont

Gets the font.

Returns

\BarcodeBakery\Common\BCGFont —

setFont()

setFont(mixed  $font) : mixed

Sets the font.

Parameters

mixed $font

BCGFont or int

Returns

mixed —

parse()

parse(mixed  $text) : mixed

Parses the text before displaying it.

Parameters

mixed $text

Returns

mixed —

getChecksum()

getChecksum() : string

Gets the checksum of a Barcode.

If no checksum is available, return FALSE.

Returns

string —

setDisplayChecksum()

setDisplayChecksum(bool  $displayChecksum) : mixed

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

bool $displayChecksum

Returns

mixed —

getForegroundColor()

getForegroundColor() : \BarcodeBakery\Common\BCGColor

Gets the foreground color of the barcode.

Returns

\BarcodeBakery\Common\BCGColor —

setForegroundColor()

setForegroundColor(mixed  $code) : mixed

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

Returns

mixed —

getBackgroundColor()

getBackgroundColor() : \BarcodeBakery\Common\BCGColor

Gets the background color of the barcode.

Returns

\BarcodeBakery\Common\BCGColor —

setBackgroundColor()

setBackgroundColor(mixed  $code) : mixed

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

Returns

mixed —

setColor()

setColor(mixed  $fg, mixed  $bg) : mixed

Sets the color.

Parameters

mixed $fg
mixed $bg

Returns

mixed —

getScale()

getScale() : int

Gets the scale of the barcode.

Returns

int —

setScale()

setScale(int  $scale) : mixed

Sets the scale of the barcode in pixel.

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

Parameters

int $scale

Returns

mixed —

draw()

draw(resource  $im) : mixed

Draws the barcode.

Parameters

resource $im

Returns

mixed —

getDimension()

getDimension(int  $w, int  $h) : int[]

Returns the maximal size of a barcode.

Parameters

int $w
int $h

Returns

int[] —

getOffsetX()

getOffsetX() : int

Gets the X offset.

Returns

int —

setOffsetX()

setOffsetX(int  $offsetX) : mixed

Sets the X offset.

Parameters

int $offsetX

Returns

mixed —

getOffsetY()

getOffsetY() : int

Gets the Y offset.

Returns

int —

setOffsetY()

setOffsetY(int  $offsetY) : mixed

Sets the Y offset.

Parameters

int $offsetY

Returns

mixed —

addLabel()

addLabel(\BarcodeBakery\Common\BCGLabel  $label) : mixed

Adds the label to the drawing.

Parameters

\BarcodeBakery\Common\BCGLabel $label

Returns

mixed —

removeLabel()

removeLabel(\BarcodeBakery\Common\BCGLabel  $label) : mixed

Removes the label from the drawing.

Parameters

\BarcodeBakery\Common\BCGLabel $label

Returns

mixed —

getLabels()

getLabels() : \BarcodeBakery\Common\BCGLabel[]

Gets the labels.

Returns

\BarcodeBakery\Common\BCGLabel[] —

clearLabels()

clearLabels() : mixed

Clears the labels.

Returns

mixed —

getQuietZone()

getQuietZone() : bool

Gets the Quiet zone.

Returns

bool —

setQuietZone()

setQuietZone(bool  $quietZone) : mixed

Sets the Quiet zone.

Parameters

bool $quietZone

Returns

mixed —

setTrackingCode()

setTrackingCode(int  $barcodeIdentifier, int  $serviceTypeIdentifier, int  $mailerIdentifier, int  $serialNumber) : mixed

Sets the tracking code.

Parameters

int $barcodeIdentifier

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

int $serviceTypeIdentifier

3 digits

int $mailerIdentifier

6 or 9 digits

int $serialNumber

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

Returns

mixed —

addDefaultLabel()

addDefaultLabel() : mixed

Adds the default label.

Returns

mixed —

validate()

validate() : mixed

Validates the input.

Returns

mixed —

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, bool  $startBar = true) : mixed

Overloaded method for drawing special barcode.

Parameters

resource $im
string $code
bool $startBar

Returns

mixed —

drawSingleBar()

drawSingleBar(mixed  $im, int  $color) : mixed

Draws a Bar of $color depending of the resolution.

Parameters

mixed $im
int $color

Returns

mixed —

nextX()

nextX() : mixed

Moving the pointer right to write a bar.

Returns

mixed —

calculateChecksum()

calculateChecksum() : mixed

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

Returns

mixed —

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, int  $x1, int  $y1, int  $x2, int  $y2) : mixed

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
int $x1
int $y1
int $x2
int $y2

Returns

mixed —

drawPixel()

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

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

Parameters

resource $im
int $x
int $y
int $color

Returns

mixed —

drawRectangle()

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

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

Parameters

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

Returns

mixed —

drawFilledRectangle()

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

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

Parameters

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

Returns

mixed —

getColor()

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

Allocates the color based on the integer.

Parameters

resource $im
int $color

Returns

resource —

getBiggestLabels()

getBiggestLabels(bool  $reversed = false) : \BarcodeBakery\Common\BCGLabel[]

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

Parameters

bool $reversed

Returns

\BarcodeBakery\Common\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) : int

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

Parameters

$number

BCNumber

Returns

int —

executeStep3()

executeStep3(string  $number) : int[]

Executes Step 3: Conversion from Binary Data to Codewords

Parameters

string $number

BCNumber

Returns

int[] —

executeStep4()

executeStep4(int[]  $codewords, int  $crc) : int[]

Executes Step 4: Inserting Additional Information into Codewords

Parameters

int[] $codewords
int $crc

Returns

int[] —

executeStep5()

executeStep5(int[]  $codewords, int  $crc) : int[]

Executes Step 5: Conversion from Codewords to Characters

Parameters

int[] $codewords
int $crc

Returns

int[] —

executeStep6()

executeStep6(int[]  $characters) : string

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

Parameters

int[] $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) : mixed

Transforms a BCNumber into unsigned char*.

Parameters

string $dec

BCNumber

Returns

mixed —