Zend_Barcode-Objects.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.barcode.objects" xmlns:xi="http://www.w3.org/2001/XInclude">
  4. <title>Zend_Barcode Objects</title>
  5. <para>
  6. Barcode objects allow you to generate barcodes independently of the rendering support. After
  7. generation, you can retrieve the barcode as an array of drawing instructions that you can
  8. provide to a renderer.
  9. </para>
  10. <para>
  11. Objects have a large number of options. Most of them are common to all objects. These
  12. options can be set in four ways:
  13. </para>
  14. <itemizedlist>
  15. <listitem>
  16. <para>
  17. As an array or a <classname>Zend_Config</classname> object passed to the
  18. constructor.
  19. </para>
  20. </listitem>
  21. <listitem>
  22. <para>
  23. As an array passed to the <methodname>setOptions()</methodname> method.
  24. </para>
  25. </listitem>
  26. <listitem>
  27. <para>
  28. As a <classname>Zend_Config</classname> object passed to the
  29. <methodname>setConfig()</methodname> method.
  30. </para>
  31. </listitem>
  32. <listitem>
  33. <para>Via individual setters for each configuration type.</para>
  34. </listitem>
  35. </itemizedlist>
  36. <example id="zend.barcode.objects.configuration">
  37. <title>Different ways to parameterize a barcode object</title>
  38. <programlisting language="php"><![CDATA[
  39. $options = array('text' => 'ZEND-FRAMEWORK', 'barHeight' => 40);
  40. // Case 1: constructor
  41. $barcode = new Zend_Barcode_Object_Code39($options);
  42. // Case 2: setOptions()
  43. $barcode = new Zend_Barcode_Object_Code39();
  44. $barcode->setOptions($options);
  45. // Case 3: setConfig()
  46. $config = new Zend_Config($options);
  47. $barcode = new Zend_Barcode_Object_Code39();
  48. $barcode->setConfig($config);
  49. // Case 4: individual setters
  50. $barcode = new Zend_Barcode_Object_Code39();
  51. $barcode->setText('ZEND-FRAMEWORK')
  52. ->setBarHeight(40);
  53. ]]></programlisting>
  54. </example>
  55. <sect2 id="zend.barcode.objects.common.options">
  56. <title>Common Options</title>
  57. <para>
  58. In the following list, the values have no units; we will use the term "unit." For
  59. example, the default value of the "thin bar" is "1 unit". The real units depend on the
  60. rendering support (see <link linkend="zend.barcode.renderers">the renderers
  61. documentation</link> for more information). Setters are each named by uppercasing
  62. the initial letter of the option and prefixing the name with "set" (e.g. "barHeight"
  63. becomes "setBarHeight"). All options have a corresponding getter prefixed with "get"
  64. (e.g. "getBarHeight"). Available options are:
  65. </para>
  66. <table id="zend.barcode.objects.common.options.table">
  67. <title>Common Options</title>
  68. <tgroup cols="4">
  69. <thead>
  70. <row>
  71. <entry>Option</entry>
  72. <entry>Data Type</entry>
  73. <entry>Default Value</entry>
  74. <entry>Description</entry>
  75. </row>
  76. </thead>
  77. <tbody>
  78. <row>
  79. <entry><emphasis>barcodeNamespace</emphasis></entry>
  80. <entry><type>String</type></entry>
  81. <entry><classname>Zend_Barcode_Object</classname></entry>
  82. <entry>
  83. Namespace of the barcode; for example, if you need to extend the
  84. embedding objects
  85. </entry>
  86. </row>
  87. <row>
  88. <entry><emphasis>barHeight</emphasis></entry>
  89. <entry><type>Integer</type></entry>
  90. <entry>50</entry>
  91. <entry>Height of the bars</entry>
  92. </row>
  93. <row>
  94. <entry><emphasis>barThickWidth</emphasis></entry>
  95. <entry><type>Integer</type></entry>
  96. <entry>3</entry>
  97. <entry>Width of the thick bar</entry>
  98. </row>
  99. <row>
  100. <entry><emphasis>barThinWidth</emphasis></entry>
  101. <entry><type>Integer</type></entry>
  102. <entry>1</entry>
  103. <entry>Width of the thin</entry>
  104. </row>
  105. <row>
  106. <entry><emphasis>factor</emphasis></entry>
  107. <entry>
  108. <type>Integer</type>, <type>Float</type>,
  109. <type>String</type> or <type>Boolean</type>
  110. </entry>
  111. <entry>1</entry>
  112. <entry>Factor by which to multiply bar widths and font sizes</entry>
  113. </row>
  114. <row>
  115. <entry><emphasis>foreColor</emphasis></entry>
  116. <entry><type>Integer</type></entry>
  117. <entry>0 (black)</entry>
  118. <entry>
  119. Color of the bar and the text. Could be provided as an integer
  120. or as a <acronym>HTML</acronym> value (e.g. "#333333")
  121. </entry>
  122. </row>
  123. <row>
  124. <entry><emphasis>backgroundColor</emphasis></entry>
  125. <entry><type>Integer</type> or <type>String</type></entry>
  126. <entry>16777125 (white)</entry>
  127. <entry>
  128. Color of the background. Could be provided as an integer
  129. or as a <acronym>HTML</acronym> value (e.g. "#333333")
  130. </entry>
  131. </row>
  132. <row>
  133. <entry><emphasis>reverseColor</emphasis></entry>
  134. <entry><type>Boolean</type></entry>
  135. <entry><constant>FALSE</constant></entry>
  136. <entry>Allow switching the color of the bar and the background</entry>
  137. </row>
  138. <row>
  139. <entry><emphasis>orientation</emphasis></entry>
  140. <entry>
  141. <type>Integer</type>, <type>Float</type>,
  142. <type>String</type> or <type>Boolean</type>
  143. </entry>
  144. <entry>0</entry>
  145. <entry>Orientation of the barcode</entry>
  146. </row>
  147. <row>
  148. <entry><emphasis>font</emphasis></entry>
  149. <entry><type>String</type> or <type>Integer</type></entry>
  150. <entry><constant>NULL</constant></entry>
  151. <entry>
  152. Font path to a <acronym>TTF</acronym> font or a number between 1 and 5
  153. if using image generation with GD (internal fonts)
  154. </entry>
  155. </row>
  156. <row>
  157. <entry><emphasis>fontSize</emphasis></entry>
  158. <entry><type>Integer</type></entry>
  159. <entry>10</entry>
  160. <entry>Size of the font (not applicable with numeric fonts)</entry>
  161. </row>
  162. <row>
  163. <entry><emphasis>withBorder</emphasis></entry>
  164. <entry><type>Boolean</type></entry>
  165. <entry><constant>FALSE</constant></entry>
  166. <entry>Draw a border around the barcode and the quiet zones</entry>
  167. </row>
  168. <row>
  169. <entry><emphasis>withQuietZones</emphasis></entry>
  170. <entry><type>Boolean</type></entry>
  171. <entry><constant>TRUE</constant></entry>
  172. <entry>Leave a quiet zone before and after the barcode</entry>
  173. </row>
  174. <row>
  175. <entry><emphasis>drawText</emphasis></entry>
  176. <entry><type>Boolean</type></entry>
  177. <entry><constant>TRUE</constant></entry>
  178. <entry>Set if the text is displayed below the barcode</entry>
  179. </row>
  180. <row>
  181. <entry><emphasis>stretchText</emphasis></entry>
  182. <entry><type>Boolean</type></entry>
  183. <entry><constant>FALSE</constant></entry>
  184. <entry>Specify if the text is stretched all along the barcode</entry>
  185. </row>
  186. <row>
  187. <entry><emphasis>withChecksum</emphasis></entry>
  188. <entry><type>Boolean</type></entry>
  189. <entry><constant>FALSE</constant></entry>
  190. <entry>
  191. Indicate whether or not the checksum is automatically added to
  192. the barcode
  193. </entry>
  194. </row>
  195. <row>
  196. <entry><emphasis>withChecksumInText</emphasis></entry>
  197. <entry><type>Boolean</type></entry>
  198. <entry><constant>FALSE</constant></entry>
  199. <entry>
  200. Indicate whether or not the checksum is displayed in the textual
  201. representation
  202. </entry>
  203. </row>
  204. <row>
  205. <entry><emphasis>text</emphasis></entry>
  206. <entry><type>String</type></entry>
  207. <entry><constant>NULL</constant></entry>
  208. <entry>The text to represent as a barcode</entry>
  209. </row>
  210. </tbody>
  211. </tgroup>
  212. </table>
  213. <sect3 id="zend.barcode.objects.common.options.barcodefont">
  214. <title>Particular case of static setBarcodeFont()</title>
  215. <para>
  216. You can set a commont font for all your objects by using the static method
  217. <methodname>Zend_Barcode_Object::setBarcodeFont()</methodname>. This value
  218. can be always be overridden for individual objects by using the
  219. <methodname>setFont()</methodname> method.
  220. </para>
  221. <programlisting language="php"><![CDATA[
  222. // In your bootstrap:
  223. Zend_Barcode_Object::setBarcodeFont('my_font.ttf');
  224. // Later in your code:
  225. Zend_Barcode::render(
  226. 'code39',
  227. 'pdf',
  228. array('text' => 'ZEND-FRAMEWORK')
  229. ); // will use 'my_font.ttf'
  230. // or:
  231. Zend_Barcode::render(
  232. 'code39',
  233. 'image',
  234. array(
  235. 'text' => 'ZEND-FRAMEWORK',
  236. 'font' => 3
  237. )
  238. ); // will use the 3rd GD internal font
  239. ]]></programlisting>
  240. </sect3>
  241. </sect2>
  242. <sect2 id="zend.barcode.objects.common.getters">
  243. <title>Common Additional Getters</title>
  244. <para></para>
  245. <table id="zend.barcode.objects.common.getters.table">
  246. <title>Common Getters</title>
  247. <tgroup cols="3">
  248. <thead>
  249. <row>
  250. <entry>Getter</entry>
  251. <entry>Data Type</entry>
  252. <entry>Description</entry>
  253. </row>
  254. </thead>
  255. <tbody>
  256. <row>
  257. <entry><methodname>getType()</methodname></entry>
  258. <entry><type>String</type></entry>
  259. <entry>
  260. Return the name of the barcode class without the namespace (e.g.
  261. <classname>Zend_Barcode_Object_Code39</classname> returns simply
  262. "code39")
  263. </entry>
  264. </row>
  265. <row>
  266. <entry><methodname>getRawText()</methodname></entry>
  267. <entry><type>String</type></entry>
  268. <entry>Return the original text provided to the object</entry>
  269. </row>
  270. <row>
  271. <entry><methodname>getTextToDisplay()</methodname></entry>
  272. <entry><type>String</type></entry>
  273. <entry>
  274. Return the text to display, including, if activated, the checksum value
  275. </entry>
  276. </row>
  277. <row>
  278. <entry><methodname>getQuietZone()</methodname></entry>
  279. <entry><type>Integer</type></entry>
  280. <entry>
  281. Return the size of the space needed before and after the barcode
  282. without any drawing
  283. </entry>
  284. </row>
  285. <row>
  286. <entry><methodname>getInstructions()</methodname></entry>
  287. <entry><type>Array</type></entry>
  288. <entry>Return drawing instructions as an array.</entry>
  289. </row>
  290. <row>
  291. <entry><methodname>getHeight($recalculate = false)</methodname></entry>
  292. <entry><type>Integer</type></entry>
  293. <entry>
  294. Return the height of the barcode calculated after possible rotation
  295. </entry>
  296. </row>
  297. <row>
  298. <entry><methodname>getWidth($recalculate = false)</methodname></entry>
  299. <entry><type>Integer</type></entry>
  300. <entry>
  301. Return the width of the barcode calculated after possible rotation
  302. </entry>
  303. </row>
  304. <row>
  305. <entry><methodname>getOffsetTop($recalculate = false)</methodname></entry>
  306. <entry><type>Integer</type></entry>
  307. <entry>
  308. Return the position of the top of the barcode calculated after
  309. possible rotation
  310. </entry>
  311. </row>
  312. <row>
  313. <entry><methodname>getOffsetLeft($recalculate = false)</methodname></entry>
  314. <entry><type>Integer</type></entry>
  315. <entry>
  316. Return the position of the left of the barcode calculated after
  317. possible rotation
  318. </entry>
  319. </row>
  320. </tbody>
  321. </tgroup>
  322. </table>
  323. </sect2>
  324. <xi:include href="Zend_Barcode-Objects_Details.xml" />
  325. </sect1>