Class for generate Barcode

 Methods

Constructor

__construct(array | \Traversable $options) 

Parameters

$options

array\Traversable

Checking of parameters after all settings

checkParams() : bool

Returns

bool

Complete drawing of the barcode

draw() : array

Returns

arrayTable of instructions

Retrieve background color of the image

getBackgroundColor() : int

Returns

int

Get height of the barcode bar

getBarHeight() : int

Returns

int

Get thickness of thick bar

getBarThickWidth() : int

Returns

int

Get thickness of thin bar

getBarThinWidth() : int

Returns

int

Retrieve barcode namespace

getBarcodeNamespace() : string

Returns

string

Retrieve if drawing of text to encode is enabled

getDrawText() : bool

Returns

bool

Get factor applying to thinBarWidth - thickBarWidth - barHeight - fontSize

getFactor() : int

Returns

int

Retrieve the font

getFont() : int | string

Returns

intstring

Retrieve the size of the font in case of TTF

getFontSize() : float

Returns

float

Retrieve color of the barcode and text

getForeColor() : int

Returns

int

Get height of the result object

getHeight(bool $recalculate) : int

Parameters

$recalculate

bool

Returns

int

Retrieve the set of drawing instructions

getInstructions() : array

Returns

array

Calculate the offset from the left of the object if an orientation is activated

getOffsetLeft(bool $recalculate) : float

Parameters

$recalculate

bool

Returns

float

Calculate the offset from the top of the object if an orientation is activated

getOffsetTop(bool $recalculate) : float

Parameters

$recalculate

bool

Returns

float

Retrieve orientation of barcode and text

getOrientation() : float

Returns

float

Quiet zone before first bar and after the last bar

getQuietZone() : int

Returns

int

Retrieve text to encode

getRawText() : string

Returns

string

Retrieve if the adjustment of the position of the characters to the position of the bars is enabled

getStretchText() : bool

Returns

bool

Retrieve text to encode

getText() : string

Returns

string

Retrieve text to display

getTextToDisplay() : string

Returns

string

Retrieve type of barcode

getType() : string

Returns

string

Get width of the result object

getWidth(bool $recalculate) : int

Parameters

$recalculate

bool

Returns

int

Retrieve if border are draw or not

getWithBorder() : bool

Returns

bool

Retrieve if the checksum character is automatically added to the barcode text

getWithChecksum() : bool

Returns

bool

Retrieve if the checksum character is automatically added to the barcode text

getWithChecksumInText() : bool

Returns

bool

Retrieve if quiet zones are draw or not

getWithQuietZones() : bool

Returns

bool

Set the color of the background

setBackgroundColor(int $value) : \Zend\Barcode\Object\ObjectInterface

Set height of the barcode bar

setBarHeight(int $value) : \Zend\Barcode\Object\ObjectInterface

Set thickness of thick bar

setBarThickWidth(int $value) : \Zend\Barcode\Object\ObjectInterface

Set thickness of thin bar

setBarThinWidth(int $value) : \Zend\Barcode\Object\ObjectInterface

Set barcode namespace for autoloading

setBarcodeNamespace(string $namespace) : \Zend\Barcode\Object\ObjectInterface

Parameters

$namespace

string

Returns

Activate/deactivate drawing of text to encode

setDrawText(bool $value) : \Zend\Barcode\Object\ObjectInterface

Parameters

$value

bool

Returns

Set factor applying to thinBarWidth - thickBarWidth - barHeight - fontSize

setFactor(int | float | string | bool $value) : \Zend\Barcode\Object\ObjectInterface

Parameters

$value

intfloatstringbool

Exceptions

\Zend\Barcode\Object\Exception\ExceptionInterface

Returns

Set the font: - if integer between 1 and 5, use gd built-in fonts - if string, $value is assumed to be the path to a TTF font

setFont(int | string $value) : \Zend\Barcode\Object\ObjectInterface

Set the size of the font in case of TTF

setFontSize(float $value) : \Zend\Barcode\Object\ObjectInterface

Set color of the barcode and text

setForeColor(string $value) : \Zend\Barcode\Object\ObjectInterface

Set barcode state from options array

setOptions(array $options) : \Zend\Barcode\Object\ObjectInterface

Parameters

$options

array

Returns

Set orientation of barcode and text

setOrientation(int | float | string | bool $value) : \Zend\Barcode\Object\ObjectInterface

Parameters

$value

intfloatstringbool

Exceptions

\Zend\Barcode\Object\Exception\ExceptionInterface

Returns

Allow fast inversion of font/bars color and background color

setReverseColor() : \Zend\Barcode\Object\ObjectInterface

Activate/deactivate the adjustment of the position of the characters to the position of the bars

setStretchText(bool $value) : \Zend\Barcode\Object\ObjectInterface

Set text to encode

setText(string $value) : \Zend\Barcode\Object\ObjectInterface

Parameters

$value

string

Returns

Activate/deactivate drawing of the bar

setWithBorder(bool $value) : \Zend\Barcode\Object\ObjectInterface

Parameters

$value

bool

Returns

Activate/deactivate the automatic generation of the checksum character added to the barcode text

setWithChecksum(bool $value) : \Zend\Barcode\Object\ObjectInterface

Parameters

$value

bool

Returns

Activate/deactivate the automatic generation of the checksum character added to the barcode text

setWithChecksumInText(bool $value) : \Zend\Barcode\Object\ObjectInterface

Activate/deactivate drawing of the quiet zones

setWithQuietZones(bool $value) : \Zend\Barcode\Object\AbstractObject

Parameters

$value

bool

Returns

Check for invalid characters

validateText(string $value) : void

Parameters

$value

string

Text to be checked

Add an instruction in the array of instructions

addInstruction(array $instruction) 

Parameters

$instruction

array

Automatically add leading zeros if barcode length is fixed

addLeadingZeros(string $text, bool $withoutChecksum) : string

Parameters

$text

string

$withoutChecksum

bool

Returns

string

Add a polygon drawing instruction in the set of instructions

addPolygon(array $points, int $color, bool $filled) 

Parameters

$points

array

$color

int

$filled

bool

Add a text drawing instruction in the set of instructions

addText(string $text, float $size, int[] $position, string $font, int $color, string $alignment, float | int $orientation) 

Parameters

$text

string

$size

float

$position

int[]

$font

string

$color

int

$alignment

string

$orientation

floatint

Height of the barcode

calculateBarcodeHeight() : int

Returns

int

Calculate the width of the barcode

calculateBarcodeWidth() : int

Returns

int

Height of the result object

calculateHeight() : int

Returns

int

Width of the result image (before any rotation)

calculateWidth() : int

Returns

int

Drawing with an angle is just allow TTF font

checkFontAndOrientation() 

Check the ratio between the thick and the thin bar

checkRatio(int $min, int $max) 

Parameters

$min

int

$max

int

Exceptions

\Zend\Barcode\Object\Exception\ExceptionInterface

Checking of parameters after all settings

checkSpecificParams() 

Check if a text is really provided to barcode

checkText(string | null $value) 

Parameters

$value

stringnull

Exceptions

\Zend\Barcode\Object\Exception\ExceptionInterface

Draw the barcode

drawBarcode() 

Partial function to draw border

drawBorder() 

Partial function to draw text

drawText() 

Set default options for particular object

getDefaultOptions() 

Allow each child to draw something else (ex: bearer bars in interleaved 2 of 5 code)

postDrawBarcode() 

Allow each child to draw something else

preDrawBarcode() 

Each child must prepare the barcode and return a table like array( 0 => array( 0 => int (visible(black) or not(white)) 1 => int (width of the bar) 2 => float (0->1 position from the top of the beginning of the bar in %) 3 => float (0->1 position from the top of the end of the bar in %) ), 1 => .

prepareBarcode() : array

.. )

Returns

array

Apply rotation on a point in X/Y dimensions

rotate(float $x1, float $y1) : array

Parameters

$x1

float

x-position before rotation

$y1

float

y-position before rotation

Returns

arrayArray of two elements corresponding to the new XY point

Standard validation for most of barcode objects

validateSpecificText(string $value, array $options) 

Parameters

$value

string

$options

array

 Properties

 

Activate automatic addition of leading zeros if barcode length is fixed

$addLeadingZeros : bool

 

Background color of the object

$backgroundColor : int

 

Height of the bar

$barHeight : int

 

Width of a thick bar

$barThickWidth : int

 

Width of a thin bar

$barThinWidth : int

 

Fix barcode length (numeric or string like 'even')

$barcodeLength : int

 

Namespace of the barcode for autoloading

$barcodeNamespace : string

 

Display (or not) human readable text

$drawText : bool

 

Factor to multiply bar and font measure (barHeight, barThinWidth, barThickWidth & fontSize)

$factor : int

 

Font resource - integer (1 to 5): corresponds to GD included fonts - string: corresponds to path of a TTF font

$font : int | string

 

Font size

$fontSize : float

 

Font and bars color of the object

$foreColor : int

 

Height of the object

$height : int

 

Set of drawing instructions

$instructions : array

 

Activation of mandatory checksum to deactivate unauthorized modification

$mandatoryChecksum : bool

 

Force quiet zones even if

$mandatoryQuietZones : bool

 

Offset from the left the object (calculated from the orientation)

$offsetLeft : int

 

Offset from the top the object (calculated from the orientation)

$offsetTop : int

 

Orientation of the barcode in degrees

$orientation : float

 

Adjust (or not) position of human readable characters with barcode

$stretchText : bool

 

Character used to substitute checksum character for validation

$substituteChecksumCharacter : mixed

 

Text to display

$text : string

 

Barcode type

$type : string

 

Width of the object

$width : int

 

Activate/deactivate border of the object

$withBorder : bool

 

Drawing of checksum

$withChecksum : bool

 

Drawing of checksum inside text

$withChecksumInText : bool

 

Activate/deactivate drawing of quiet zones

$withQuietZones : bool