1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.barcode.objects" xmlns:xi="http://www.w3.org/2001/XInclude">
4 <title>Zend_Barcode Objects</title>
7 Barcode objects allow you to generate barcodes independently of the rendering support. After
8 generation, you can retrieve the barcode as an array of drawing instructions that you can
13 Objects have a large number of options. Most of them are common to all objects. These
14 options can be set in four ways:
20 As an array or a <classname>Zend_Config</classname> object passed to the
27 As an array passed to the <methodname>setOptions()</methodname> method.
33 As a <classname>Zend_Config</classname> object passed to the
34 <methodname>setConfig()</methodname> method.
39 <para>Via individual setters for each configuration type.</para>
43 <example id="zend.barcode.objects.configuration">
44 <title>Different ways to parameterize a barcode object</title>
46 <programlisting language="php"><![CDATA[
47 $options = array('text' => 'ZEND-FRAMEWORK', 'barHeight' => 40);
49 // Case 1: constructor
50 $barcode = new Zend_Barcode_Object_Code39($options);
52 // Case 2: setOptions()
53 $barcode = new Zend_Barcode_Object_Code39();
54 $barcode->setOptions($options);
56 // Case 3: setConfig()
57 $config = new Zend_Config($options);
58 $barcode = new Zend_Barcode_Object_Code39();
59 $barcode->setConfig($config);
61 // Case 4: individual setters
62 $barcode = new Zend_Barcode_Object_Code39();
63 $barcode->setText('ZEND-FRAMEWORK')
68 <sect2 id="zend.barcode.objects.common.options">
69 <title>Common Options</title>
72 In the following list, the values have no units; we will use the term "unit." For
73 example, the default value of the "thin bar" is "1 unit". The real units depend on the
74 rendering support (see <link linkend="zend.barcode.renderers">the renderers
75 documentation</link> for more information). Setters are each named by uppercasing
76 the initial letter of the option and prefixing the name with "set" (e.g. "barHeight"
77 becomes "setBarHeight"). All options have a corresponding getter prefixed with "get"
78 (e.g. "getBarHeight"). Available options are:
81 <table id="zend.barcode.objects.common.options.table">
82 <title>Common Options</title>
88 <entry>Data Type</entry>
89 <entry>Default Value</entry>
90 <entry>Description</entry>
96 <entry><emphasis>barcodeNamespace</emphasis></entry>
97 <entry><type>String</type></entry>
98 <entry><classname>Zend_Barcode_Object</classname></entry>
101 Namespace of the barcode; for example, if you need to extend the
107 <entry><emphasis>barHeight</emphasis></entry>
108 <entry><type>Integer</type></entry>
110 <entry>Height of the bars</entry>
113 <entry><emphasis>barThickWidth</emphasis></entry>
114 <entry><type>Integer</type></entry>
116 <entry>Width of the thick bar</entry>
120 <entry><emphasis>barThinWidth</emphasis></entry>
121 <entry><type>Integer</type></entry>
123 <entry>Width of the thin</entry>
127 <entry><emphasis>factor</emphasis></entry>
128 <entry><type>Integer</type></entry>
130 <entry>Factor by which to multiply bar widths and font sizes</entry>
134 <entry><emphasis>foreColor</emphasis></entry>
135 <entry><type>Integer</type></entry>
136 <entry>0 (black)</entry>
139 Color of the bar and the text. Could be provided as an integer
140 or as a <acronym>HTML</acronym> value (e.g. "#333333")
145 <entry><emphasis>backgroundColor</emphasis></entry>
146 <entry><type>Integer</type> or <type>String</type></entry>
147 <entry>16777125 (white)</entry>
150 Color of the background. Could be provided as an integer
151 or as a <acronym>HTML</acronym> value (e.g. "#333333")
156 <entry><emphasis>reverseColor</emphasis></entry>
157 <entry><type>Boolean</type></entry>
158 <entry><constant>FALSE</constant></entry>
159 <entry>Allow switching the color of the bar and the background</entry>
163 <entry><emphasis>orientation</emphasis></entry>
164 <entry><type>Integer</type></entry>
166 <entry>Orientation of the barcode</entry>
170 <entry><emphasis>font</emphasis></entry>
171 <entry><type>String</type> or <type>Integer</type></entry>
172 <entry><constant>NULL</constant></entry>
175 Font path to a <acronym>TTF</acronym> font or a number between 1 and 5
176 if using image generation with GD (internal fonts)
181 <entry><emphasis>fontSize</emphasis></entry>
182 <entry><type>Integer</type></entry>
184 <entry>Size of the font (not applicable with numeric fonts)</entry>
188 <entry><emphasis>withBorder</emphasis></entry>
189 <entry><type>Boolean</type></entry>
190 <entry><constant>FALSE</constant></entry>
191 <entry>Draw a border around the barcode and the quiet zones</entry>
195 <entry><emphasis>withQuietZones</emphasis></entry>
196 <entry><type>Boolean</type></entry>
197 <entry><constant>TRUE</constant></entry>
198 <entry>Leave a quiet zone before and after the barcode</entry>
202 <entry><emphasis>drawText</emphasis></entry>
203 <entry><type>Boolean</type></entry>
204 <entry><constant>TRUE</constant></entry>
205 <entry>Set if the text is displayed below the barcode</entry>
209 <entry><emphasis>stretchText</emphasis></entry>
210 <entry><type>Boolean</type></entry>
211 <entry><constant>FALSE</constant></entry>
212 <entry>Specify if the text is stretched all along the barcode</entry>
216 <entry><emphasis>withChecksum</emphasis></entry>
217 <entry><type>Boolean</type></entry>
218 <entry><constant>FALSE</constant></entry>
221 Indicate whether or not the checksum is automatically added to
227 <entry><emphasis>withChecksumInText</emphasis></entry>
228 <entry><type>Boolean</type></entry>
229 <entry><constant>FALSE</constant></entry>
232 Indicate whether or not the checksum is displayed in the textual
238 <entry><emphasis>text</emphasis></entry>
239 <entry><type>String</type></entry>
240 <entry><constant>NULL</constant></entry>
241 <entry>The text to represent as a barcode</entry>
247 <sect3 id="zend.barcode.objects.common.options.barcodefont">
248 <title>Particular case of static setBarcodeFont()</title>
251 You can set a commont font for all your objects by using the static method
252 <methodname>Zend_Barcode_Object::setBarcodeFont()</methodname>. This value
253 can be always be overridden for individual objects by using the
254 <methodname>setFont()</methodname> method.
257 <programlisting language="php"><![CDATA[
258 // In your bootstrap:
259 Zend_Barcode_Object::setBarcodeFont('my_font.ttf');
261 // Later in your code:
262 Zend_Barcode::render(
265 array('text' => 'ZEND-FRAMEWORK')
266 ); // will use 'my_font.ttf'
269 Zend_Barcode::render(
273 'text' => 'ZEND-FRAMEWORK',
276 ); // will use the 3rd GD internal font
281 <sect2 id="zend.barcode.objects.common.getters">
282 <title>Common Additional Getters</title>
286 <table id="zend.barcode.objects.common.getters.table">
287 <title>Common Getters</title>
292 <entry>Getter</entry>
293 <entry>Data Type</entry>
294 <entry>Description</entry>
300 <entry><methodname>getType()</methodname></entry>
301 <entry><type>String</type></entry>
304 Return the name of the barcode class without the namespace (e.g.
305 <classname>Zend_Barcode_Object_Code39</classname> returns simply
311 <entry><methodname>getRawText()</methodname></entry>
312 <entry><type>String</type></entry>
313 <entry>Return the original text provided to the object</entry>
317 <entry><methodname>getTextToDisplay()</methodname></entry>
318 <entry><type>String</type></entry>
321 Return the text to display, including, if activated, the checksum value
326 <entry><methodname>getQuietZone()</methodname></entry>
327 <entry><type>Integer</type></entry>
330 Return the size of the space needed before and after the barcode
336 <entry><methodname>getInstructions()</methodname></entry>
337 <entry><type>Array</type></entry>
338 <entry>Return drawing instructions as an array.</entry>
342 <entry><methodname>getHeight($recalculate = false)</methodname></entry>
343 <entry><type>Integer</type></entry>
346 Return the height of the barcode calculated after possible rotation
351 <entry><methodname>getWidth($recalculate = false)</methodname></entry>
352 <entry><type>Integer</type></entry>
355 Return the width of the barcode calculated after possible rotation
360 <entry><methodname>getOffsetTop($recalculate = false)</methodname></entry>
361 <entry><type>Integer</type></entry>
364 Return the position of the top of the barcode calculated after
370 <entry><methodname>getOffsetLeft($recalculate = false)</methodname></entry>
371 <entry><type>Integer</type></entry>
374 Return the position of the left of the barcode calculated after
383 <xi:include href="Zend_Barcode-Objects_Details.xml" />