This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
phptsmadmin/includes/jpgraph/docs/chunkhtml/ch25s04.html
2011-05-28 19:51:52 +10:00

462 lines
37 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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>