32
1
mirror of https://github.com/vdm-io/tcpdf.git synced 2024-11-22 21:05:10 +00:00
This commit is contained in:
nicolaasuni 2010-06-06 13:18:48 +02:00
parent d70bab7164
commit 03b7a147c5
19 changed files with 96 additions and 41 deletions

View File

@ -1,9 +1,9 @@
<?php
//============================================================+
// File name : 2dbarcodes.php
// Version : 1.0.005
// Version : 1.0.006
// Begin : 2009-04-07
// Last Update : 2010-06-05
// Last Update : 2010-06-06
// Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// -------------------------------------------------------------------
@ -40,14 +40,14 @@
* @copyright 2009-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @version 1.0.005
* @version 1.0.006
*/
/**
* PHP class to creates array representations for 2D barcodes to be used with TCPDF (http://www.tcpdf.org).<br>
* @name TCPDFBarcode
* @package com.tecnick.tcpdf
* @version 1.0.005
* @version 1.0.006
* @author Nicola Asuni
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
@ -68,7 +68,7 @@ class TCPDF2DBarcode {
* <li>$arrcode['num_cols'] required number of columns</li>
* <li>$arrcode['bcode'][$r][$c] value of the cell is $r row and $c column (0 = transparent, 1 = black)</li></ul>
* @param string $code code to print
* @param string $type type of barcode: <ul><li>RAW: raw mode - comma-separad list of array rows</li><li>RAW2: raw mode - array rows are surrounded by square parenthesis.</li><li>QRCODE : QR-CODE Low error correction</li><li>QRCODE,L : QR-CODE Low error correction</li><li>QRCODE,M : QR-CODE Medium error correction</li><li>QRCODE,Q : QR-CODE Better error correction</li><li>QRCODE,H : QR-CODE Best error correction</li><li>PDF417 : PDF417 (ISO/IEC 15438:2006)</li><li>PDF417,a,e : PDF417 with aspect ratio (a = width/height) and error correction level (e = 0-8)</li></ul>
* @param string $type type of barcode: <ul><li>RAW: raw mode - comma-separad list of array rows</li><li>RAW2: raw mode - array rows are surrounded by square parenthesis.</li><li>QRCODE : QR-CODE Low error correction</li><li>QRCODE,L : QR-CODE Low error correction</li><li>QRCODE,M : QR-CODE Medium error correction</li><li>QRCODE,Q : QR-CODE Better error correction</li><li>QRCODE,H : QR-CODE Best error correction</li><li>PDF417 : PDF417 (ISO/IEC 15438:2006)</li><li>PDF417,a,e,t,s,f,o0,o1,o2,o3,o4,o5,o6 : PDF417 with parameters: a = aspect ratio (width/height); e = error correction level (0-8); t = total number of macro segments; s = macro segment index (0-99998); f = file ID; o0 = File Name (text); o1 = Segment Count (numeric); o2 = Time Stamp (numeric); o3 = Sender (text); o4 = Addressee (text); o5 = File Size (numeric); o6 = Checksum (numeric). NOTES: Parameters t, s and f are required for a Macro Control Block, all other parametrs are optional. To use a comma character ',' on text options, replace it with the character 255: "\xff".</li></ul>
*/
public function __construct($code, $type) {
$this->setBarcode($code, $type);
@ -85,7 +85,7 @@ class TCPDF2DBarcode {
/**
* Set the barcode.
* @param string $code code to print
* @param string $type type of barcode: <ul><li>RAW: raw mode - comma-separad list of array rows</li><li>RAW2: raw mode - array rows are surrounded by square parenthesis.</li><li>QRCODE : QR-CODE Low error correction</li><li>QRCODE,L : QR-CODE Low error correction</li><li>QRCODE,M : QR-CODE Medium error correction</li><li>QRCODE,Q : QR-CODE Better error correction</li><li>QRCODE,H : QR-CODE Best error correction</li><li>PDF417 : PDF417 (ISO/IEC 15438:2006)</li><li>PDF417,a,e : PDF417 with aspect ratio (a = width/height) and error correction level (e = 0-8)</li></ul>
* @param string $type type of barcode: <ul><li>RAW: raw mode - comma-separad list of array rows</li><li>RAW2: raw mode - array rows are surrounded by square parenthesis.</li><li>QRCODE : QR-CODE Low error correction</li><li>QRCODE,L : QR-CODE Low error correction</li><li>QRCODE,M : QR-CODE Medium error correction</li><li>QRCODE,Q : QR-CODE Better error correction</li><li>QRCODE,H : QR-CODE Best error correction</li><li>PDF417 : PDF417 (ISO/IEC 15438:2006)</li><li>PDF417,a,e,t,s,f,o0,o1,o2,o3,o4,o5,o6 : PDF417 with parameters: a = aspect ratio (width/height); e = error correction level (0-8); t = total number of macro segments; s = macro segment index (0-99998); f = file ID; o0 = File Name (text); o1 = Segment Count (numeric); o2 = Time Stamp (numeric); o3 = Sender (text); o4 = Addressee (text); o5 = File Size (numeric); o6 = Checksum (numeric). NOTES: Parameters t, s and f are required for a Macro Control Block, all other parametrs are optional. To use a comma character ',' on text options, replace it with the character 255: "\xff".</li></ul>
* @return array
*/
public function setBarcode($code, $type) {
@ -113,7 +113,21 @@ class TCPDF2DBarcode {
} else {
$ecl = intval($mode[2]);
}
$qrcode = new PDF417($code, $ecl, $aspectratio);
// set macro block
$macro = array();
if (isset($mode[3]) AND ($mode[3] !== '') AND isset($mode[4]) AND ($mode[4] !== '') AND isset($mode[5]) AND ($mode[5] !== '')) {
$macro['segment_total'] = intval($mode[3]);
$macro['segment_index'] = intval($mode[4]);
$macro['file_id'] = strtr($mode[5], "\xff", ',');
for ($i = 0; $i < 7; ++$i) {
$o = $i + 6;
if (isset($mode[$o]) AND ($mode[$o] !== '')) {
// add option
$macro['option_'.$i] = strtr($mode[$o], "\xff", ',');
}
}
}
$qrcode = new PDF417($code, $ecl, $aspectratio, $macro);
$this->barcode_array = $qrcode->getBarcodeArray();
break;
}

View File

@ -55,7 +55,7 @@
<div class="credit">
<hr />
Documentation generated on Sun, 06 Jun 2010 13:13:30 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Sun, 06 Jun 2010 13:18:39 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -5548,7 +5548,7 @@ $frame)</code>
<div class="credit">
<hr />
Documentation generated on Sun, 06 Jun 2010 13:13:31 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Sun, 06 Jun 2010 13:18:40 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -25691,7 +25691,7 @@ $file)</code>
<div class="credit">
<hr />
Documentation generated on Sun, 06 Jun 2010 13:13:32 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Sun, 06 Jun 2010 13:18:41 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -80,7 +80,7 @@ Source Location: /2dbarcodes.php<br /><br />
<h4>Version:</h4>
<ul>
<li>1.0.005</li>
<li>1.0.006</li>
</ul>
@ -128,7 +128,7 @@ PHP class to creates array representations for 2D barcodes to be used with TCPDF
<td><b>author:</b>&nbsp;&nbsp;</td><td>Nicola Asuni</td>
</tr>
<tr>
<td><b>version:</b>&nbsp;&nbsp;</td><td>1.0.005</td>
<td><b>version:</b>&nbsp;&nbsp;</td><td>1.0.006</td>
</tr>
<tr>
<td><b>link:</b>&nbsp;&nbsp;</td><td><a href="http://www.tcpdf.org">http://www.tcpdf.org</a></td>
@ -218,7 +218,7 @@ $type)</code>
<tr>
<td class="type">string&nbsp;&nbsp;</td>
<td><b>$type</b>&nbsp;&nbsp;</td>
<td>type of barcode: <ul><li>RAW: raw mode - comma-separad list of array rows</li><li>RAW2: raw mode - array rows are surrounded by square parenthesis.</li><li>QRCODE : QR-CODE Low error correction</li><li>QRCODE,L : QR-CODE Low error correction</li><li>QRCODE,M : QR-CODE Medium error correction</li><li>QRCODE,Q : QR-CODE Better error correction</li><li>QRCODE,H : QR-CODE Best error correction</li><li>PDF417 : PDF417 (ISO/IEC 15438:2006)</li><li>PDF417,a,e : PDF417 with aspect ratio (a = width/height) and error correction level (e = 0-8)</li></ul></td>
<td>type of barcode: <ul><li>RAW: raw mode - comma-separad list of array rows</li><li>RAW2: raw mode - array rows are surrounded by square parenthesis.</li><li>QRCODE : QR-CODE Low error correction</li><li>QRCODE,L : QR-CODE Low error correction</li><li>QRCODE,M : QR-CODE Medium error correction</li><li>QRCODE,Q : QR-CODE Better error correction</li><li>QRCODE,H : QR-CODE Best error correction</li><li>PDF417 : PDF417 (ISO/IEC 15438:2006)</li><li>PDF417,a,e,t,s,f,o0,o1,o2,o3,o4,o5,o6 : PDF417 with parameters: a = aspect ratio (width/height); e = error correction level (0-8); t = total number of macro segments; s = macro segment index (0-99998); f = file ID; o0 = File Name (text); o1 = Segment Count (numeric); o2 = Time Stamp (numeric); o3 = Sender (text); o4 = Addressee (text); o5 = File Size (numeric); o6 = Checksum (numeric). NOTES: Parameters t, s and f are required for a Macro Control Block, all other parametrs are optional. To use a comma character ',' on text options, replace it with the character 255: &quot;\xff&quot;.</li></ul></td>
</tr>
</table>
</div><br />
@ -285,7 +285,7 @@ $type)</code>
<tr>
<td class="type">string&nbsp;&nbsp;</td>
<td><b>$type</b>&nbsp;&nbsp;</td>
<td>type of barcode: <ul><li>RAW: raw mode - comma-separad list of array rows</li><li>RAW2: raw mode - array rows are surrounded by square parenthesis.</li><li>QRCODE : QR-CODE Low error correction</li><li>QRCODE,L : QR-CODE Low error correction</li><li>QRCODE,M : QR-CODE Medium error correction</li><li>QRCODE,Q : QR-CODE Better error correction</li><li>QRCODE,H : QR-CODE Best error correction</li><li>PDF417 : PDF417 (ISO/IEC 15438:2006)</li><li>PDF417,a,e : PDF417 with aspect ratio (a = width/height) and error correction level (e = 0-8)</li></ul></td>
<td>type of barcode: <ul><li>RAW: raw mode - comma-separad list of array rows</li><li>RAW2: raw mode - array rows are surrounded by square parenthesis.</li><li>QRCODE : QR-CODE Low error correction</li><li>QRCODE,L : QR-CODE Low error correction</li><li>QRCODE,M : QR-CODE Medium error correction</li><li>QRCODE,Q : QR-CODE Better error correction</li><li>QRCODE,H : QR-CODE Best error correction</li><li>PDF417 : PDF417 (ISO/IEC 15438:2006)</li><li>PDF417,a,e,t,s,f,o0,o1,o2,o3,o4,o5,o6 : PDF417 with parameters: a = aspect ratio (width/height); e = error correction level (0-8); t = total number of macro segments; s = macro segment index (0-99998); f = file ID; o0 = File Name (text); o1 = Segment Count (numeric); o2 = Time Stamp (numeric); o3 = Sender (text); o4 = Addressee (text); o5 = File Size (numeric); o6 = Checksum (numeric). NOTES: Parameters t, s and f are required for a Macro Control Block, all other parametrs are optional. To use a comma character ',' on text options, replace it with the character 255: &quot;\xff&quot;.</li></ul></td>
</tr>
</table>
</div><br />
@ -296,7 +296,7 @@ $type)</code>
<div class="credit">
<hr />
Documentation generated on Sun, 06 Jun 2010 13:13:30 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Sun, 06 Jun 2010 13:18:39 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -1374,7 +1374,7 @@ $type)</code>
<div class="credit">
<hr />
Documentation generated on Sun, 06 Jun 2010 13:13:30 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Sun, 06 Jun 2010 13:18:39 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -79,7 +79,7 @@ PHP class to creates array representations for 2D barcodes to be used with TCPDF
<td><b>author:</b>&nbsp;&nbsp;</td><td>Nicola Asuni</td>
</tr>
<tr>
<td><b>version:</b>&nbsp;&nbsp;</td><td>1.0.005</td>
<td><b>version:</b>&nbsp;&nbsp;</td><td>1.0.006</td>
</tr>
<tr>
<td><b>copyright:</b>&nbsp;&nbsp;</td><td>2009-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com</td>
@ -102,7 +102,7 @@ PHP class to creates array representations for 2D barcodes to be used with TCPDF
<div class="credit">
<hr />
Documentation generated on Sun, 06 Jun 2010 13:13:30 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Sun, 06 Jun 2010 13:18:39 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -102,7 +102,7 @@ PHP class to creates array representations for common 1D barcodes to be used wit
<div class="credit">
<hr />
Documentation generated on Sun, 06 Jun 2010 13:13:30 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Sun, 06 Jun 2010 13:18:39 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -539,7 +539,7 @@ Configuration file for TCPDF.<br /><br /><br /><br />
<div class="credit">
<hr />
Documentation generated on Sun, 06 Jun 2010 13:13:36 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Sun, 06 Jun 2010 13:18:45 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -94,7 +94,7 @@ Array of WEB safe colors.<br /><br /><br /><br />
<div class="credit">
<hr />
Documentation generated on Sun, 06 Jun 2010 13:13:31 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Sun, 06 Jun 2010 13:18:40 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -477,7 +477,7 @@ string $string, [int $split_length = 1])</code>
<div class="credit">
<hr />
Documentation generated on Sun, 06 Jun 2010 13:13:31 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Sun, 06 Jun 2010 13:18:40 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -121,7 +121,7 @@ unicode data<br /><br /></div>
<div class="credit">
<hr />
Documentation generated on Sun, 06 Jun 2010 13:13:32 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Sun, 06 Jun 2010 13:18:41 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -243,7 +243,7 @@ Unicode data for TCPDF library.<br /><br /><br /><br />
<div class="credit">
<hr />
Documentation generated on Sun, 06 Jun 2010 13:13:36 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Sun, 06 Jun 2010 13:18:45 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -1976,7 +1976,7 @@
<a href="elementindex.html#top">top</a><br>
<div class="credit">
<hr />
Documentation generated on Sun, 06 Jun 2010 13:13:30 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Sun, 06 Jun 2010 13:18:39 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -2005,7 +2005,7 @@
<a href="elementindex_com-tecnick-tcpdf.html#top">top</a><br>
<div class="credit">
<hr />
Documentation generated on Sun, 06 Jun 2010 13:13:30 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Sun, 06 Jun 2010 13:18:39 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -35,7 +35,7 @@
<a href="#Post-parsing">Post-parsing</a><br>
<div class="credit">
<hr />
Documentation generated on Sun, 06 Jun 2010 13:13:36 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Sun, 06 Jun 2010 13:18:45 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -64,7 +64,7 @@
This documentation was generated by <a href="http://www.phpdoc.org">phpDocumentor v1.4.3</a><br />
<div class="credit">
<hr />
Documentation generated on Sun, 06 Jun 2010 13:13:30 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Sun, 06 Jun 2010 13:18:39 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -64,7 +64,7 @@
This documentation was generated by <a href="http://www.phpdoc.org">phpDocumentor v1.4.3</a><br />
<div class="credit">
<hr />
Documentation generated on Sun, 06 Jun 2010 13:13:30 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Sun, 06 Jun 2010 13:18:39 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -1,9 +1,9 @@
<?php
//============================================================+
// File name : pdf417.php
// Version : 1.0.000
// Version : 1.0.001
// Begin : 2010-06-03
// Last Update : 2010-06-05
// Last Update : 2010-06-06
// Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// -------------------------------------------------------------------
@ -53,7 +53,7 @@
* @copyright 2010-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @version 1.0.000
* @version 1.0.001
*/
// definitions
@ -99,7 +99,7 @@ if (!class_exists('PDF417', false)) {
* @copyright 2010-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @version 1.0.000
* @version 1.0.001
*/
class PDF417 {
@ -541,9 +541,10 @@ if (!class_exists('PDF417', false)) {
* @param string $code code to represent using PDF417
* @param int $ecl error correction level (0-8); default -1 = automatic correction level
* @param float $aspectratio the width to height of the symbol (excluding quiet zones)
* òparam array $macro information for macro block
* @access public
*/
public function __construct($code, $ecl=-1, $aspectratio=2) {
public function __construct($code, $ecl=-1, $aspectratio=2, $macro=array()) {
$barcode_array = array();
if ((is_null($code)) OR ($code == '\0') OR ($code == '')) {
return false;
@ -551,21 +552,54 @@ if (!class_exists('PDF417', false)) {
// get the input sequence array
$sequence = $this->getInputSequences($code);
$codewords = array(); // array of code-words
$numcw = 0; //number of codewords
foreach($sequence as $seq) {
$cw = $this->getCompaction($seq[0], $seq[1]);
$numcw += count($cw);
$cw = $this->getCompaction($seq[0], $seq[1], true);
$codewords = array_merge($codewords, $cw);
}
if ($codewords[0] == 900) {
// Text Alpha is the default mode, so remove the first code
array_shift($codewords);
--$numcw;
}
// count number of codewords
$numcw = count($codewords);
if ($numcw > 925) {
// reached maximum data codeword capacity
return false;
}
// build macro control block codewords
if (!empty($macro)) {
$macrocw = array();
// beginning of macro control block
$macrocw[] = 928;
// segment index
$cw = $this->getCompaction(902, sprintf('%05d', $macro['segment_index']), false);
$macrocw = array_merge($macrocw, $cw);
// file ID
$cw = $this->getCompaction(900, $macro['file_id'], false);
$macrocw = array_merge($macrocw, $cw);
// optional fields
$optmodes = array(900,902,902,900,900,902,902);
$optsize = array(-1,2,4,-1,-1,-1,2);
foreach ($optmodes as $k => $omode) {
if (isset($macro['option_'.$k])) {
$macrocw[] = 923;
$macrocw[] = $k;
if ($optsize[$k] == 2) {
$macro['option_'.$k] = sprintf('%05d', $macro['option_'.$k]);
} elseif ($optsize[$k] == 4) {
$macro['option_'.$k] = sprintf('%010d', $macro['option_'.$k]);
}
$cw = $this->getCompaction($omode, $macro['option_'.$k], false);
$macrocw = array_merge($macrocw, $cw);
}
}
if ($macro['segment_index'] == ($macro['segment_total'] - 1)) {
// end of control block
$macrocw[] = 922;
}
// update total codewords
$numcw += count($macrocw);
}
// set error correction level
$ecl = $this->getErrorCorrectionLevel($ecl, $numcw);
// number of codewords for error correction
@ -613,6 +647,10 @@ if (!class_exists('PDF417', false)) {
$codewords = array_merge($codewords, array_fill(0, $pad, 900));
}
}
if (!empty($macro)) {
// add macro section
$codewords = array_merge($codewords, $macrocw);
}
// Symbol Lenght Descriptor (number of data codewords including Symbol Lenght Descriptor and pad codewords)
$sld = $size - $errsize;
// add symbol length description
@ -843,10 +881,11 @@ if (!class_exists('PDF417', false)) {
* Compact data by mode.
* @param int $mode compaction mode number
* @param string $code data to compact
* @param boolean $addmode if true add the mode codeword at first position
* @return array of codewords
* @access protected
*/
protected function getCompaction($mode, $code) {
protected function getCompaction($mode, $code, $addmode=true) {
$cw = array(); // array of codewords to return
switch($mode) {
case 900: { // Text Compaction mode latch
@ -953,8 +992,10 @@ if (!class_exists('PDF417', false)) {
break;
}
}
// add the compaction mode codeword at the beginning
array_unshift($cw, $mode);
if ($addmode) {
// add the compaction mode codeword at the beginning
array_unshift($cw, $mode);
}
return $cw;
}