Documentation

Zend_Barcode Renderers - Zend_Barcode

Zend_Barcode Renderers

Renderers have some common options. These options can be set in four ways:

  • As an array or a Zend_Config object passed to the constructor.

  • As an array passed to the setOptions() method.

  • As a Zend_Config object passed to the setConfig() method.

  • As discrete values passed to individual setters.

Example #1 Different ways to parameterize a renderer object

  1. $options = array('topOffset' => 10);
  2.  
  3. // Case 1
  4. $renderer = new Zend_Barcode_Renderer_Pdf($options);
  5.  
  6. // Case 2
  7. $renderer = new Zend_Barcode_Renderer_Pdf();
  8. $renderer->setOptions($options);
  9.  
  10. // Case 3
  11. $config   = new Zend_Config($options);
  12. $renderer = new Zend_Barcode_Renderer_Pdf();
  13. $renderer->setConfig($config);
  14.  
  15. // Case 4
  16. $renderer = new Zend_Barcode_Renderer_Pdf();
  17. $renderer->setTopOffset(10);

Common Options

In the following list, the values have no unit; we will use the term "unit." For example, the default value of the "thin bar" is "1 unit." The real units depend on the rendering support. The individual setters are obtained by uppercasing the initial letter of the option and prefixing the name with "set" (e.g. "barHeight" => "setBarHeight"). All options have a correspondant getter prefixed with "get" (e.g. "getBarHeight"). Available options are:

Common Options
Option Data Type Default Value Description
rendererNamespace String Zend_Barcode_Renderer Namespace of the renderer; for example, if you need to extend the renderers
horizontalPosition String "left" Can be "left", "center" or "right". Can be useful with PDF or if the setWidth() method is used with an image renderer.
verticalPosition String "top" Can be "top", "middle" or "bottom". Can be useful with PDF or if the setHeight() method is used with an image renderer.
leftOffset Integer 0 Top position of the barcode inside the renderer. If used, this value will override the "horizontalPosition" option.
topOffset Integer 0 Top position of the barcode inside the renderer. If used, this value will override the "verticalPosition" option.
automaticRenderError Boolean TRUE Whether or not to automatically render errors. If an exception occurs, the provided barcode object will be replaced with an Error representation. Note that some errors (or exceptions) can not be rendered.
moduleSize Float 1 Size of a rendering module in the support.
barcode Zend_Barcode_Object NULL The barcode object to render.

An additional getter exists: getType(). It returns the name of the renderer class without the namespace (e.g. Zend_Barcode_Renderer_Image returns "image").

Zend_Barcode_Renderer_Image

The Image renderer will draw the instruction list of the barcode object in an image resource. The component requires the GD extension. The default width of a module is 1 pixel.

Available option are:

Zend_Barcode_Renderer_Image Options
Option Data Type Default Value Description
height Integer 0 Allow you to specify the height of the result image. If "0", the height will be calculated by the barcode object.
width Integer 0 Allow you to specify the width of the result image. If "0", the width will be calculated by the barcode object.
imageType String "png" Specify the image format. Can be "png", "jpeg", "jpg" or "gif".

Zend_Barcode_Renderer_Pdf

The PDF renderer will draw the instruction list of the barcode object in a PDF document. The default width of a module is 0.5 point.

There are no particular options for this renderer.

Zend_Barcode_Renderer_Svg

The SVG renderer will draw the instruction list of the barcode object in a SVG document. The default width of a module is 1 pixel.

Available option are:

Zend_Barcode_Renderer_Svg Options
Option Data Type Default Value Description
height Integer 0 Allow you to specify the height of the result image. If "0", the height will be calculated by the barcode object.
width Integer 0 Allow you to specify the width of the result image. If "0", the width will be calculated by the barcode object.

Copyright

© 2006-2021 by Zend by Perforce. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts