Barcode creation using Zend_Barcode classUsing Zend_Barcode::factoryZend_Barcode uses a factory method to create an instance of a renderer that extends Zend_Barcode_Renderer_RendererAbstract. The factory method accepts five arguments.
Example #1 Getting a Renderer with Zend_Barcode::factory() Zend_Barcode::factory() instantiates barcode objects and renderers and ties them together. In this first example, we will use the Code39 barcode type together with the Image renderer.
Example #2 Using Zend_Barcode::factory() with Zend_Config objects You may pass a Zend_Config object to the factory in order to create the necessary objects. The following example is functionally equivalent to the previous.
Drawing a barcodeWhen you draw the barcode, you retrieve the resource in which the barcode is drawn. To draw a barcode, you can call the draw() of the renderer, or simply use the proxy method provided by Zend_Barcode. Example #3 Drawing a barcode with the renderer object
Example #4 Drawing a barcode with Zend_Barcode::draw()
Renderering a barcodeWhen you render a barcode, you draw the barcode, you send the headers and you send the resource (e.g. to a browser). To render a barcode, you can call the render() method of the renderer or simply use the proxy method provided by Zend_Barcode. Example #5 Renderering a barcode with the renderer object
This will generate this barcode:
Example #6 Renderering a barcode with Zend_Barcode::render()
This will generate the same barcode as the previous example.
|