Class for generate Barcode

category Zend
package Zend_Barcode
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License

 Methods

Constructor

__construct(array|\Zend_Config $options = null

Parameters

$options

array\Zend_Config

Checking of parameters after all settings

checkParams() : boolean

Returns

boolean

Complete drawing of the barcode

draw() : array

Returns

arrayTable of instructions

Retrieve background color of the image

getBackgroundColor() : integer

Returns

integer

Get height of the barcode bar

getBarHeight() : integer

Returns

integer

Get thickness of thick bar

getBarThickWidth() : integer

Returns

integer

Get thickness of thin bar

getBarThinWidth() : integer

Returns

integer

Retrieve barcode namespace

getBarcodeNamespace() : string

Returns

string

Retrieve if drawing of text to encode is enabled

getDrawText() : boolean

Returns

boolean

Get factor applying to thinBarWidth - thickBarWidth - barHeight - fontSize

getFactor() : integer

Returns

integer

Retrieve the font

getFont() : integer | string

Returns

integerstring

Retrieve the size of the font in case of TTF

getFontSize() : float

Returns

float

Retrieve color of the barcode and text

getForeColor() : \unknown

Returns

\unknown

Get height of the result object

getHeight(boolean $recalculate = false) : integer

Parameters

$recalculate

boolean

Returns

integer

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(boolean $recalculate = false) : float

Parameters

$recalculate

boolean

Returns

float

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

getOffsetTop(boolean $recalculate = false) : float

Parameters

$recalculate

boolean

Returns

float

Retrieve orientation of barcode and text

getOrientation() : float

Returns

float

Quiet zone before first bar and after the last bar

getQuietZone() : integer

Returns

integer

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() : boolean

Returns

boolean

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(boolean $recalculate = false) : integer

Parameters

$recalculate

boolean

Returns

integer

Retrieve if border are draw or not

getWithBorder() : boolean

Returns

boolean

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

getWithChecksum() : boolean

Returns

boolean

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

getWithChecksumInText() : boolean

Returns

boolean

Retrieve if quiet zones are draw or not

getWithQuietZones() : boolean

Returns

boolean

Set the color of the background

setBackgroundColor(integer $value) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$value

integer

Exceptions

\Zend_Barcode_Object_Exception

Returns

\Zend_Barcode_Object_ObjectAbstract

Set height of the barcode bar

setBarHeight(integer $value) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$value

integer

Exceptions

\Zend_Barcode_Object_Exception

Returns

\Zend_Barcode_Object_ObjectAbstract

Set thickness of thick bar

setBarThickWidth(integer $value) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$value

integer

Exceptions

\Zend_Barcode_Object_Exception

Returns

\Zend_Barcode_Object_ObjectAbstract

Set thickness of thin bar

setBarThinWidth(integer $value) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$value

integer

Exceptions

\Zend_Barcode_Object_Exception

Returns

\Zend_Barcode_Object_ObjectAbstract

Set the font for all instances of barcode

setBarcodeFont(string $font) 
Static

Parameters

$font

string

Set barcode namespace for autoloading

setBarcodeNamespace(string $namespace) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$namespace

string

Returns

\Zend_Barcode_Object_ObjectAbstract

Set barcode state from config object

setConfig(\Zend_Config $config) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$config

\Zend_Config

Returns

\Zend_Barcode_Object_ObjectAbstract

Activate/deactivate drawing of text to encode

setDrawText(boolean $value) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$value

boolean

Returns

\Zend_Barcode_Object_ObjectAbstract

Set factor applying to thinBarWidth - thickBarWidth - barHeight - fontSize

setFactor(integer|float|string|boolean $value) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$value

integerfloatstringboolean

Exceptions

\Zend_Barcode_Object_Exception

Returns

\Zend_Barcode_Object_ObjectAbstract

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(integer|string $value) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$value

integerstring

Exceptions

\Zend_Barcode_Object_Exception

Returns

\Zend_Barcode_Object_ObjectAbstract

Set the size of the font in case of TTF

setFontSize(float $value) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$value

float

Exceptions

\Zend_Barcode_Object_Exception

Returns

\Zend_Barcode_Object_ObjectAbstract

Set color of the barcode and text

setForeColor(string $value) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$value

string

Exceptions

\Zend_Barcode_Object_Exception

Returns

\Zend_Barcode_Object_ObjectAbstract

Set barcode state from options array

setOptions(array $options) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$options

array

Returns

\Zend_Barcode_Object_ObjectAbstract

Set orientation of barcode and text

setOrientation(integer|float|string|boolean $value) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$value

integerfloatstringboolean

Exceptions

\Zend_Barcode_Object_Exception

Returns

\Zend_Barcode_Object_ObjectAbstract

Allow fast inversion of font/bars color and background color

setReverseColor() : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Returns

\Zend_Barcode_Object_ObjectAbstract

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

setStretchText(boolean $value) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$value

boolean

Exceptions

\Zend_Barcode_Object_Exception

Returns

\Zend_Barcode_Object_ObjectAbstract

Set text to encode

setText(string $value) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$value

string

Returns

\Zend_Barcode_Object_ObjectAbstract

Activate/deactivate drawing of the bar

setWithBorder(boolean $value) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$value

boolean

Returns

\Zend_Barcode_Object_ObjectAbstract

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

setWithChecksum(boolean $value) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$value

boolean

Returns

\Zend_Barcode_Object_ObjectAbstract

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

setWithChecksumInText(boolean $value) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$value

boolean

Exceptions

\Zend_Barcode_Object_Exception

Returns

\Zend_Barcode_Object_ObjectAbstract

Activate/deactivate drawing of the quiet zones

setWithQuietZones(boolean $value) : \Zend_Barcode_Object_ObjectAbstract
fluent This method is part of a fluent interface and will return the same instance

Parameters

$value

boolean

Returns

\Zend_Barcode_Object_ObjectAbstract

Check for invalid characters

validateText(string $value) 

Parameters

$value

string

Text to be ckecked

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, boolean $withoutChecksum = false) : string

Parameters

$text

string

$withoutChecksum

boolean

Returns

string

Add a polygon drawing instruction in the set of instructions

_addPolygon(array $points, integer $color = null, boolean $filled = true

Parameters

$points

array

$color

integer

$filled

boolean

Add a text drawing instruction in the set of instructions

_addText(string $text, float $size, array $position, string $font, integer $color, string $alignment = 'center', float|integer $orientation = 0

Parameters

$text

string

$size

float

$position

array

$font

string

$color

integer

$alignment

string

$orientation

floatinteger

Height of the barcode

_calculateBarcodeHeight() : integer

Returns

integer

Calculate the width of the barcode

_calculateBarcodeWidth() : integer

Returns

integer

Height of the result object

_calculateHeight() : integer

Returns

integer

Width of the result image (before any rotation)

_calculateWidth() : integer

Returns

integer

Drawing with an angle is just allow TTF font

_checkFontAndOrientation() 

Exceptions

\Zend_Barcode_Object_Exception

Checking of parameters after all settings

_checkParams() 

Check the ratio between the thick and the thin bar

_checkRatio(integer $min = 2, integer $max = 3

Parameters

$min

integer

$max

integer

Exceptions

\Zend_Barcode_Object_Exception

Check if a text is really provided to barcode

_checkText(string|null $value = null

Parameters

$value

stringnull

Exceptions

\Zend_Barcode_Object_Exception

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

_validateText(string $value, array $options = array()

Parameters

$value

string

$options

array

Exceptions

\Zend_Barcode_Object_Exception

 Properties

 

Activate automatic addition of leading zeros if barcode length is fixed

$_addLeadingZeros : 

Default

true
 

Background color of the object

$_backgroundColor : integer

Default

16777215
 

Height of the bar

$_barHeight : integer

Default

50
 

Width of a thick bar

$_barThickWidth : integer

Default

3
 

Width of a thin bar

$_barThinWidth : integer

Default

1
 

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

$_barcodeLength : 

Default

null
 

Namespace of the barcode for autoloading

$_barcodeNamespace : string

Default

'Zend_Barcode_Object'
 

Display (or not) human readable text

$_drawText : boolean

Default

true
 

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

$_factor : integer

Default

1
 

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

$_font : integer | string

Default

null
 

Font size

$_fontSize : float

Default

10
 

Font and bars color of the object

$_foreColor : integer

Default

0
 

Height of the object

$_height : integer

Default

null
 

Set of drawing instructions

$_instructions : array

Default

array()
 

Activation of mandatory checksum to deactivate unauthorized modification

$_mandatoryChecksum : 

Default

false
 

Force quiet zones even if

$_mandatoryQuietZones : boolean

Default

false
 

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

$_offsetLeft : integer

Default

null
 

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

$_offsetTop : integer

Default

null
 

Orientation of the barcode in degrees

$_orientation : float

Default

0
 

TTF font name: can be set before instanciation of the object

$_staticFont : string

Default

null
Static
 

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

$_stretchText : boolean

Default

false
 

Character used to substitute checksum character for validation

$_substituteChecksumCharacter : 

Default

0
 

Text to display

$_text : string

Default

null
 

Barcode type

$_type : string

Default

null
 

Width of the object

$_width : integer

Default

null
 

Activate/deactivate border of the object

$_withBorder : boolean

Default

false
 

Drawing of checksum

$_withChecksum : boolean

Default

false
 

Drawing of checksum inside text

$_withChecksumInText : boolean

Default

false
 

Activate/deactivate drawing of quiet zones

$_withQuietZones : boolean

Default

true