Create Code 128 Barcode with Zend Barcode Component that contains an FNC3 function character

2.5k views Asked by At

I'm trying to work out how to inlclude an FNC3 control character in my Zend Barcode.

For example this barcode contains the FNC3 character and then 0B

barcode

Compare that to a barcode that doesn't contain this character.

enter image description here

I am unable to work out how to (1) change the charset of a type 128 barcode. (2) Include a control character (FNC1-4) in a type128 barcode.

I've tried passing though all kinds of combinations like the following into the 'text' param of the options array. http://framework.zend.com/manual/en/zend.barcode.objects.html

Is this possible? How does one pass an FNC3 Character. Is this the literal string 'FNC3' or am I missing something.

Edit:

I have tried using ü / Ç characters in my text string but PHP trips up every time.

1

There are 1 answers

3
Denis Ryabov On

Seems there is no way to include FNC3 character in current version of \Zend\Barcode\Object\Code128. I would made a copy of Code128.php, replaced 'FNC3' to a character with a charcode greater 128, e.g. chr(228) (it's ASCII code of the character in Barcode Font according to http://www.barcoderesource.com/code128_barcode_map.html):

protected $charSets = array(
    'A' => array(
    /*...*/
        chr(228), 'FNC2', 'SHIFT', 'Code C', 'Code B', 'FNC4', 'FNC1',
    /*...*/
    'B' => array(
    /*...*/
        chr(228), 'FNC2', 'SHIFT', 'Code C', 'FNC4', 'Code A', 'FNC1',

and then use chr(228) in your strings (e.g. chr(228).'0B'). And finally you can override original class using composer's loader or creating a module to do it in standard way.