Blame view

site/jpgraph/docs/chunkhtml/ch25s04.html 37.2 KB
d72ac078   Guillaume   Ajout graphe V1.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
  <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Specifying the PDF417 parameters</title><link rel="stylesheet" type="text/css" href="manual.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch25.html" title="Chapter 25. PDF417 (2D-Barcode)"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Specifying the PDF417 parameters</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center">Chapter 25. PDF417 (2D-Barcode)</th><td width="20%" align="right"> </td></tr></table><hr></div><div class="sect1" title="Specifying the PDF417 parameters"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2600352"></a>Specifying the PDF417 parameters</h2></div></div></div>
          
          <p>
              </p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>
                  <p>The following section is not meant as a general introduction to the way PDF417
                      barcode is specified. It assumes that the reader has a basic understanding of
                      the nature of PDF417 encoding. This section will focus on how to make use of the
                      methods in the library to specify the various settings for the PDF417 barcodes.
                  </p>
              </div><p>
          </p>
          <div class="sect2" title="Specifying encoding and input data"><div class="titlepage"><div><div><h3 class="title"><a name="id2600768"></a>Specifying encoding and input data</h3></div></div></div>
              
              <p>The absolute simplest way of encoding data is simply to create a simple string
                  representing the data to be encoded and then pass that string as the first argument
                  to the <code class="code">Stroke()</code> method in the backend. The encoder will then analyze
                  the input data and choose the most efficient space saving encoding schema for this
                  data. </p>
              <p>The PDF417 standard allows 3 different compaction schema that can be used to
                  minimize the number of codewords used for a particular data string. This also means
                  that a particular data string may have several different valid barcodes that
                  visually looks different. </p>
              <p>The available compaction modes are:</p>
              <p>
                  </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
                          <p><span class="bold"><strong>Alpha compaction mode</strong></span> (also known as
                              Text compaction mode). Efficient encoding of ASCII 32-126, (inclusively)
                              i.e. the normal alphabet including numbers. Encodes 1.8 characters per
                              codeword.</p>
                      </li><li class="listitem">
                          <p><span class="bold"><strong>Numeric compaction mode.</strong></span> Efficient
                              encoding of numeric data. For long consecutive strings of digits this
                              gives a better compaction than the alpha mode. Numeric compaction
                              encodes about 2.9 digits per codeword.</p>
                      </li><li class="listitem">
                          <p><span class="bold"><strong>Byte compaction mode.</strong></span> The least
                              efficient encoding. Used only when there is a need to encode byte values
                              as is, i.e. values in the range 0-255. Please note that many barcode
                              readers, especially those with a keyboard wedge, don't send back the
                              proper encoding for ASCII values lower than 32 or higher than 126. Byte
                              compaction mode encodes roughly 1.2 byte per codeword.</p>
                      </li></ul></div><p>
              </p>
              <p>When the automatic encoding is chosen this will create an optimum encoding (from a
                  size perspective) of the supplied data. This includes shifting encoding method in
                  the middle of the data one or several time depending on the structure of the data. </p>
              <p>It is also possible to manually control the exact encodation of the input data.
                  This is done by supplying one or more data tuples where the first entry in the tuple
                  is the compaction schema and the second the data. To encode the data manually the
                  following structure must then be followed:</p>
              <p>
                  </p><div class="figure"><a name="id2600868"></a><p class="title"><b>Figure 25.9. Structure for manually specified encodation schema</b></p><div class="figure-contents">
                      
                      <pre class="screen">$data = array( array( &lt;encoding_mode1&gt; , &lt;data1&gt; ),
                 array( &lt;encoding_mode2&gt; , &lt;data2&gt; ),
                           ...
                 array( &lt;encoding_modeN&gt; , &lt;dataN&gt; ));</pre>
                  </div></div><p><br class="figure-break">
              </p>
              <p>The encoding mode is specified as one of three symbolic constants</p>
              <p>
                  </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
                          <p><code class="code">USE_TC</code>, (short for <span class="bold"><strong>USE</strong></span>-<span class="bold"><strong>T</strong></span>ext<span class="bold"><strong>C</strong></span>ompaction) Use Text compaction schema</p>
                      </li><li class="listitem">
                          <p><code class="code">USE_NC</code>, (short for <span class="bold"><strong>USE</strong></span>-<span class="bold"><strong>N</strong></span>umerical-<span class="bold"><strong>C</strong></span>ompaction) Use Numeric compaction
                              schema</p>
                      </li><li class="listitem">
                          <p><code class="code">USE_BC</code>, (short for <span class="bold"><strong>USE</strong></span>-<span class="bold"><strong>B</strong></span>yte<span class="bold"><strong>C</strong></span>ompaction) Use Byte compaction schema</p>
                      </li></ul></div><p>
              </p>
              <p>and the data is specified as a regular text string. Each section of data must
                  therefore have the compaction mode specified. </p>
              <p><span class="bold"><strong>Example 1:</strong></span></p>
              <p>In the following example we will assume that we want to encode the data string </p>
              <p>
                  </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
  </pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$data=&quot;1234567890&quot;</span></pre></td></tr></table></div><p>
              </p>
              <p>To use automatic encoding then there is nothing more than specifying this data to
                  the <code class="code">Backend::Stroke()</code> method as</p>
              <p>
                  </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
  </pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$backend-&gt;Stroke($data);</span></pre></td></tr></table></div><p>
              </p>
              <p>If instead we wanted to make sure that only alpha mode (text) compaction schema is
                  used the input data would have to be changed to </p>
              <p>
                  </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
  2
  3
  4
  5
  6
  </pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
  </span><span class="hl-var">$data</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">1234567890</span><span class="hl-quotes">&quot;</span><span class="hl-code"> 
  </span><span class="hl-var">$newdata</span><span class="hl-code"> = </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-identifier">USE_TC</span><span class="hl-code">, </span><span class="hl-var">$data</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-brackets">)</span><span class="hl-code">;
  ...
  </span><span class="hl-var">$backend</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-var">$newdata</span><span class="hl-brackets">)</span><span class="hl-code">;
  </span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
              </p>
              <p>this will then force the input string to be encoded using only the text compaction
                  schema.</p>
              <p>If instead we wanted to enforce only numeric compaction the code would have to be
                  changed to</p>
              <p>
                  </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
  2
  3
  4
  5
  6
  </pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
  </span><span class="hl-var">$data</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">1234567890</span><span class="hl-quotes">&quot;</span><span class="hl-code"> 
  </span><span class="hl-var">$newdata</span><span class="hl-code"> = </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-identifier">USE_NC</span><span class="hl-code">, </span><span class="hl-var">$data</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-brackets">)</span><span class="hl-code">;
  ...
  </span><span class="hl-var">$backend</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-var">$newdata</span><span class="hl-brackets">)</span><span class="hl-code">;
  </span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
              </p>
              <p>this will then force the input data string to be encoded using numeric compaction
                  schema. ∎</p>
              <p>In the above example we just used a single compaction schema to use multiple
                  encodation schema we just need to split our data for each of the compaction mode we
                  want to use and create an input array. An example will make this clear.</p>
              <p><span class="bold"><strong>Example 2:</strong></span></p>
              <p>We will assume that we want to encode the string <code class="code">"1234abc567"</code> by
                  using numeric compaction for the first 4 digits, then use text compaction for the
                  three letters and finally go back to numeric compaction schema for the last three
                  digits. For this to work we would have to create an input array as shown below. </p>
              <p>
                  </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
  2
  3
  4
  5
  6
  7
  </pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
  </span><span class="hl-var">$newdata</span><span class="hl-code"> = </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-identifier">USE_NC</span><span class="hl-code">, </span><span class="hl-quotes">'</span><span class="hl-string">1234</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">, 
                   </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-identifier">USE_TC</span><span class="hl-code">, </span><span class="hl-quotes">'</span><span class="hl-string">abc</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">, 
                   </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-identifier">USE_NC</span><span class="hl-code">, </span><span class="hl-quotes">'</span><span class="hl-string">567</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-brackets">)</span><span class="hl-code">;
  ...
  </span><span class="hl-var">$backend</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-var">$newdata</span><span class="hl-brackets">)</span><span class="hl-code">;
  </span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
              </p>
              <p></p>
              <p>
                  </p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>
                      <p>Normally there are very few reasons to specify the encodation schema
                          manually and it is therefore better to let the library determine the optimum
                          encoding by itself.</p>
                  </div><p>
              </p>
              <div class="sect3" title="Using byte compaction mode"><div class="titlepage"><div><div><h4 class="title"><a name="id2601094"></a>Using byte compaction mode</h4></div></div></div>
                  
                  <p>Using byte compaction mode is however slightly more complex. The reason is
                      that we need, for technical reasons, specify if the size (length) of the data to
                      be encoded is an even multiple of 6 or not. </p>
                  <p>Hence, there are actually two Byte code compaction schema </p>
                  <p>
                      </p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
                              <p><code class="code">USE_BC_E6</code> (for even multiples of 6) </p>
                          </li><li class="listitem">
                              <p><code class="code">USE_BC_O6</code> (for odd data).</p>
                          </li></ol></div><p>
                  </p>
                  <p>So to encode data using byte compaction mode the following template should be
                      used to determine the proper byte compaction variant.</p>
                  <p>
                      </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
  2
  3
  4
  5
  6
  </pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
  </span><span class="hl-var">$even6</span><span class="hl-code"> = </span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-identifier">strlen</span><span class="hl-brackets">(</span><span class="hl-var">$data</span><span class="hl-brackets">)</span><span class="hl-code"> % </span><span class="hl-number">6</span><span class="hl-code"> === </span><span class="hl-number">0</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-code">;
  </span><span class="hl-var">$newdata</span><span class="hl-code"> = </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-var">$even6</span><span class="hl-code"> ? </span><span class="hl-identifier">USE_BC_E6</span><span class="hl-code"> : </span><span class="hl-identifier">USE_BC_O6</span><span class="hl-code">, </span><span class="hl-var">$data</span><span class="hl-brackets">)</span><span class="hl-brackets">)</span><span class="hl-code">;
  ...
  </span><span class="hl-var">$backend</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-var">$newdata</span><span class="hl-brackets">)</span><span class="hl-code">;
  </span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
                  </p>
                  <p>
                      </p><div class="caution" title="Caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3>
                          <p>Remember that <code class="code">strlen()</code> is not multi byte character
                              encodation safe. If multi-byte characters should be encoded then the
                                  <code class="code">mb_strlen()</code> should be used.</p>
                      </div><p>
                  </p>
                  <p>
                      </p><div class="caution" title="Caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3>
                          <p>Note that several keyboard wedge barcode scanners do not handle byte
                              values &lt; 32 or &gt; 127 properly.</p>
                      </div><p>
                  </p>
              </div>
          </div>
          <div class="sect2" title="Encoder option: Adjusting the number of data columns"><div class="titlepage"><div><div><h3 class="title"><a name="id2601186"></a>Encoder option: Adjusting the number of data columns</h3></div></div></div>
              
              <p>PDF417 barcode is made up of a number of rows and columns. The library allows the
                  specification of the number of columns and it will then determine the necessary
                  number of rows to hold all the given data + the error correction information. </p>
              <p>Since each row has some overhead (start/stop and sync codewords) the overall area
                  taken by the barcode will be minimized by trying to use as many columns as possible.
                  The standards allow for up to 30 columns (and 90 rows). The most practical limit is
                  how wide data the scanner is able to handle. Most hand hold scanner will usually not
                  work very reliable with barcodes which are more than ~10cm wide.</p>
          </div>
          <div class="sect2" title="Encoder option: Adjusting the error level"><div class="titlepage"><div><div><h3 class="title"><a name="id2601209"></a>Encoder option: Adjusting the error level</h3></div></div></div>
              
              <p>All PDF417 barcodes have a minimum of two error detection codewords. Above that
                  the user is free to specify a higher level which will allow not only error detection
                  but also (some) error correction.</p>
              <p>The error level determines how much redundancy is added in the barcode label. A
                  high level of redundancy ensures that a partially damaged barcode can still be
                  correctly read by the barcode scanner. The downside is that the higher the error
                  level the larger the barcode gets and since the total number of codewords in a
                  PDF417 barcode has a maximum limit of 928 also less real data. <a class="xref" href="ch25s04.html#table.pdf417-error-levels" title="Table 25.1. Available error levels">Table 25.1. Available error levels</a> shows the available error levels and
                  how that will impact the maximum data payload. <a class="xref" href="ch25s04.html#table.pdf417-error-levels" title="Table 25.1. Available error levels">Table 25.1. Available error levels</a> also shows the error correcting
                  capacity. For example using error level 4 means that 15 of the codewords can have
                  errors and still be corrected.</p>
              <p>
                  </p><div class="table"><a name="table.pdf417-error-levels"></a><p class="title"><b>Table 25.1. Available error levels</b></p><div class="table-contents">
                      
                      <table summary="Available error levels" border="1"><colgroup><col class="c1"><col class="c2"><col class="newCol3"><col class="c3"></colgroup><thead><tr><th>Error level </th><th>
                                      <p>Error correction </p>
                                      <p>codewords</p>
                                  </th><th>
                                      <p>Error correction </p>
                                      <p>capacity</p>
                                  </th><th>
                                      <p>Maximum </p>
                                      <p>payload</p>
                                  </th></tr></thead><tbody><tr><td align="center">
                                      <p>0</p>
                                  </td><td align="center">
                                      <p>2</p>
                                  </td><td align="center">0</td><td align="center">
                                      <p>923</p>
                                  </td></tr><tr><td align="center">
                                      <p>1</p>
                                  </td><td align="center">
                                      <p>4</p>
                                  </td><td align="center">1</td><td align="center">
                                      <p>921</p>
                                  </td></tr><tr><td align="center">
                                      <p>2</p>
                                  </td><td align="center">
                                      <p>8</p>
                                  </td><td align="center">3</td><td align="center">
                                      <p>917</p>
                                  </td></tr><tr><td align="center">
                                      <p>3</p>
                                  </td><td align="center">
                                      <p>16</p>
                                  </td><td align="center">7</td><td align="center">
                                      <p>909</p>
                                  </td></tr><tr><td align="center">
                                      <p>4</p>
                                  </td><td align="center">
                                      <p>32</p>
                                  </td><td align="center">15</td><td align="center">
                                      <p>893</p>
                                  </td></tr><tr><td align="center">
                                      <p>5</p>
                                  </td><td align="center">
                                      <p>64</p>
                                  </td><td align="center">31</td><td align="center">
                                      <p>861</p>
                                  </td></tr><tr><td align="center">
                                      <p>6</p>
                                  </td><td align="center">
                                      <p>128</p>
                                  </td><td align="center">63</td><td align="center">
                                      <p>797</p>
                                  </td></tr><tr><td align="center">
                                      <p>7</p>
                                  </td><td align="center">
                                      <p>256</p>
                                  </td><td align="center">127</td><td align="center">
                                      <p>669</p>
                                  </td></tr><tr><td align="center">
                                      <p>8</p>
                                  </td><td align="center">
                                      <p>512</p>
                                  </td><td align="center">255</td><td align="center">
                                      <p>413</p>
                                  </td></tr></tbody></table>
                  </div></div><p><br class="table-break">
              </p>
              <p>The recommended minimum error level is a dependent on the payload size and is
                  given below.</p>
              <p>
                  </p><div class="table"><a name="id2601724"></a><p class="title"><b>Table 25.2. Recommended error levels</b></p><div class="table-contents">
                      
                      <table summary="Recommended error levels" border="1"><colgroup><col class="c1"><col class="c2"></colgroup><thead><tr><th>
                                      <p>Data codewords</p>
                                  </th><th>
                                      <p>Recommended </p>
                                      <p>error level</p>
                                  </th></tr></thead><tbody><tr><td>
                                      <p>1 to 40</p>
                                  </td><td align="center">
                                      <p>2</p>
                                  </td></tr><tr><td>
                                      <p>41 to 160</p>
                                  </td><td align="center">
                                      <p>3</p>
                                  </td></tr><tr><td>
                                      <p>161 to 320</p>
                                  </td><td align="center">
                                      <p>4</p>
                                  </td></tr><tr><td>
                                      <p>321 to 863</p>
                                  </td><td align="center">
                                      <p>5</p>
                                  </td></tr></tbody></table>
                  </div></div><p><br class="table-break">
              </p>
              <p>Note that the number of codewords is not the same thing as, for example, the
                  number of digits or letters in a string to be encoded. Depending on the chosen
                  encoding the number of symbols per codeword is always &gt; 1. For example in numeric
                  compaction mode (encoding) each codewords encode, on average, 2.93 digits. </p>
              <p>The error level is specified as an integer in the range [0-8] inclusively and can
                  be specified when creating a particular encoder. For example the code below uses the
                  default error correction (2). </p>
              <p>
                  </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
  2
  3
  4
  5
  6
  7
  </pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
  </span><span class="hl-comment">//</span><span class="hl-comment"> Use 10-columns for data</span><span class="hl-comment"></span><span class="hl-code">
  </span><span class="hl-var">$columns</span><span class="hl-code"> =</span><span class="hl-number">10</span><span class="hl-code">;
   
  </span><span class="hl-comment">//</span><span class="hl-comment"> Create a new encode using the default error correction</span><span class="hl-comment"></span><span class="hl-code">
  </span><span class="hl-var">$encoder</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">PDF417Barcode</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-var">$columns</span><span class="hl-brackets">)</span><span class="hl-code">;
  </span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
              </p>
              <p>While the following specifies an error correction level of 6 </p>
              <p>
                  </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
  2
  3
  4
  5
  6
  7
  </pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
  </span><span class="hl-var">$columns</span><span class="hl-code"> = </span><span class="hl-number">10</span><span class="hl-code">; </span><span class="hl-comment">//</span><span class="hl-comment"> Use 10-columns for data</span><span class="hl-comment"></span><span class="hl-code">
  </span><span class="hl-var">$errlevel</span><span class="hl-code"> = </span><span class="hl-number">6</span><span class="hl-code">; </span><span class="hl-comment">//</span><span class="hl-comment"> Error correction level 6</span><span class="hl-comment"></span><span class="hl-code">
   
  </span><span class="hl-comment">//</span><span class="hl-comment"> Create a new encode using the default error correction</span><span class="hl-comment"></span><span class="hl-code">
  </span><span class="hl-var">$encoder</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">PDF417Barcode</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-var">$columns</span><span class="hl-code">, </span><span class="hl-var">$errlevel</span><span class="hl-brackets">)</span><span class="hl-code">;
  </span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
              </p>
              <p>In addition to specifying the number of data columns and error level in the
                  creation of the encoder it is also possible to adjust them afterwards. </p>
              <p>For example, it might be necessary to create the encoder in the beginning of a
                  script and then use the same encoder with different settings controlled by, for
                  example, entries in a DB. </p>
              <p>The two encoder methods</p>
              <p>
                  </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
                          <p><code class="code">Encoder::SetErrLevel($aErrLevel)</code></p>
                      </li><li class="listitem">
                          <p><code class="code">Encoder::SetColumns($aColumns)</code></p>
                      </li></ul></div><p>
              </p>
              <p>are used for this purpose. The code snippet below does the exact same things as
                  the code snippet above but using these two methods after the encoder has been
                  instantiated instead.</p>
              <p>
                  </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
  2
  3
  4
  5
  6
  7
  8
  9
  </pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
  </span><span class="hl-var">$columns</span><span class="hl-code"> = </span><span class="hl-number">10</span><span class="hl-code">; </span><span class="hl-comment">//</span><span class="hl-comment"> Use 10-columns for data</span><span class="hl-comment"></span><span class="hl-code">
  </span><span class="hl-var">$errlevel</span><span class="hl-code"> = </span><span class="hl-number">6</span><span class="hl-code">; </span><span class="hl-comment">//</span><span class="hl-comment"> Error correction level 6</span><span class="hl-comment"></span><span class="hl-code">
   
  </span><span class="hl-comment">//</span><span class="hl-comment"> Create a new encode using the default error correction</span><span class="hl-comment"></span><span class="hl-code">
  </span><span class="hl-var">$encoder</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">PDF417Barcode</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
  </span><span class="hl-var">$encoder</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetColumns</span><span class="hl-brackets">(</span><span class="hl-var">$columns</span><span class="hl-brackets">)</span><span class="hl-code">;
  </span><span class="hl-var">$encoder</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetErrLevel</span><span class="hl-brackets">(</span><span class="hl-var">$errlevel</span><span class="hl-brackets">)</span><span class="hl-code">;
  </span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
              </p>
          </div>
          <div class="sect2" title="Truncated PDF417"><div class="titlepage"><div><div><h3 class="title"><a name="id2601957"></a>Truncated PDF417</h3></div></div></div>
              
              <p>
                  </p><div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3>
                      <p>Not all PDF417 barcode readers can handle truncated PDF417</p>
                  </div><p>
              </p>
              <p>In situations where the physical size of the label is restricted one might use the
                  truncated version of the PDF417 code. </p>
              <p>This works by simply stripping of some redundant information on the right side of
                  the barcode. This will also make the barcode more sensible for damage. </p>
              <p>The two images below shows a normal version together with the truncated version
                  (both barcodes encode the same information). </p>
              <p>
                  </p><div class="informaltable">
                      <table border="0"><colgroup><col class="c1"><col class="c2"></colgroup><tbody><tr><td>
                                      <p>
                                          </p><div class="figure"><a name="id2602035"></a><p class="title"><b>Figure 25.10. Normal PDF417</b></p><div class="figure-contents">
                                              
                                              <div class="mediaobject"><img src="images/pdf417_trunc01.png" alt="Normal PDF417"></div>
                                          </div></div><p><br class="figure-break">
                                      </p>
                                  </td><td>
                                      <p>
                                          </p><div class="figure"><a name="id2602069"></a><p class="title"><b>Figure 25.11. Truncated PDF417</b></p><div class="figure-contents">
                                              
                                              <div class="mediaobject"><img src="images/pdf417_trunc02.png" alt="Truncated PDF417"></div>
                                          </div></div><p><br class="figure-break">
                                      </p>
                                  </td></tr></tbody></table>
                  </div><p>
              </p>
              <p>To use the truncated version the method the following encoder method is
                  used</p>
              <p>
                  </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
                          <p><code class="code">Encoder::SetTruncated($aFlg=true)</code></p>
                      </li></ul></div><p>
              </p>
              <p>The following code snippet shows how this can be used</p>
              <p>
                  </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  11
  </pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
  </span><span class="hl-var">$columns</span><span class="hl-code"> = </span><span class="hl-number">10</span><span class="hl-code">; </span><span class="hl-comment">//</span><span class="hl-comment"> Use 10-columns for data</span><span class="hl-comment"></span><span class="hl-code">
  </span><span class="hl-var">$errlevel</span><span class="hl-code"> = </span><span class="hl-number">4</span><span class="hl-code">; </span><span class="hl-comment">//</span><span class="hl-comment"> Error correction level 4</span><span class="hl-comment"></span><span class="hl-code">
  </span><span class="hl-var">$truncated</span><span class="hl-code"> = </span><span class="hl-reserved">true</span><span class="hl-code">;
   
  </span><span class="hl-comment">//</span><span class="hl-comment"> Create a new encode using the default error correction</span><span class="hl-comment"></span><span class="hl-code">
  </span><span class="hl-var">$encoder</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">PDF417Barcode</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
  </span><span class="hl-var">$encoder</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetTruncated</span><span class="hl-brackets">(</span><span class="hl-var">$truncated</span><span class="hl-brackets">)</span><span class="hl-code">;
  </span><span class="hl-var">$encoder</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetColumns</span><span class="hl-brackets">(</span><span class="hl-var">$columns</span><span class="hl-brackets">)</span><span class="hl-code">;
  </span><span class="hl-var">$encoder</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetErrLevel</span><span class="hl-brackets">(</span><span class="hl-var">$errlevel</span><span class="hl-brackets">)</span><span class="hl-code">;
  </span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
              </p>
          </div>
      </div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"> </td><td width="20%" align="center"><a accesskey="u" href="ch25.html">Up</a></td><td width="40%" align="right"> </td></tr><tr><td width="40%" align="left" valign="top"> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>