diff --git a/2dbarcodes.php b/2dbarcodes.php
index c0f3ddb..d4e2ddd 100644
--- a/2dbarcodes.php
+++ b/2dbarcodes.php
@@ -1,9 +1,9 @@
* @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 {
*
$arrcode['num_cols'] required number of columns
* $arrcode['bcode'][$r][$c] value of the cell is $r row and $c column (0 = transparent, 1 = black)
* @param string $code code to print
- * @param string $type type of barcode: - RAW: raw mode - comma-separad list of array rows
- RAW2: raw mode - array rows are surrounded by square parenthesis.
- QRCODE : QR-CODE Low error correction
- QRCODE,L : QR-CODE Low error correction
- QRCODE,M : QR-CODE Medium error correction
- QRCODE,Q : QR-CODE Better error correction
- QRCODE,H : QR-CODE Best error correction
- PDF417 : PDF417 (ISO/IEC 15438:2006)
- PDF417,a,e : PDF417 with aspect ratio (a = width/height) and error correction level (e = 0-8)
+ * @param string $type type of barcode: - RAW: raw mode - comma-separad list of array rows
- RAW2: raw mode - array rows are surrounded by square parenthesis.
- QRCODE : QR-CODE Low error correction
- QRCODE,L : QR-CODE Low error correction
- QRCODE,M : QR-CODE Medium error correction
- QRCODE,Q : QR-CODE Better error correction
- QRCODE,H : QR-CODE Best error correction
- PDF417 : PDF417 (ISO/IEC 15438:2006)
- 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".
*/
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: - RAW: raw mode - comma-separad list of array rows
- RAW2: raw mode - array rows are surrounded by square parenthesis.
- QRCODE : QR-CODE Low error correction
- QRCODE,L : QR-CODE Low error correction
- QRCODE,M : QR-CODE Medium error correction
- QRCODE,Q : QR-CODE Better error correction
- QRCODE,H : QR-CODE Best error correction
- PDF417 : PDF417 (ISO/IEC 15438:2006)
- PDF417,a,e : PDF417 with aspect ratio (a = width/height) and error correction level (e = 0-8)
+ * @param string $type type of barcode: - RAW: raw mode - comma-separad list of array rows
- RAW2: raw mode - array rows are surrounded by square parenthesis.
- QRCODE : QR-CODE Low error correction
- QRCODE,L : QR-CODE Low error correction
- QRCODE,M : QR-CODE Medium error correction
- QRCODE,Q : QR-CODE Better error correction
- QRCODE,H : QR-CODE Best error correction
- PDF417 : PDF417 (ISO/IEC 15438:2006)
- 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".
* @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;
}
diff --git a/doc/classtrees_com-tecnick-tcpdf.html b/doc/classtrees_com-tecnick-tcpdf.html
index 19aefff..159dcf2 100644
--- a/doc/classtrees_com-tecnick-tcpdf.html
+++ b/doc/classtrees_com-tecnick-tcpdf.html
@@ -55,7 +55,7 @@
diff --git a/doc/com-tecnick-tcpdf/QRcode.html b/doc/com-tecnick-tcpdf/QRcode.html
index 4b65ad0..1d44a2e 100644
--- a/doc/com-tecnick-tcpdf/QRcode.html
+++ b/doc/com-tecnick-tcpdf/QRcode.html
@@ -5548,7 +5548,7 @@ $frame)
diff --git a/doc/com-tecnick-tcpdf/TCPDF.html b/doc/com-tecnick-tcpdf/TCPDF.html
index 1d0dc93..97f08f0 100644
--- a/doc/com-tecnick-tcpdf/TCPDF.html
+++ b/doc/com-tecnick-tcpdf/TCPDF.html
@@ -25691,7 +25691,7 @@ $file)
diff --git a/doc/com-tecnick-tcpdf/TCPDF2DBarcode.html b/doc/com-tecnick-tcpdf/TCPDF2DBarcode.html
index 26aa0cb..5b024a4 100644
--- a/doc/com-tecnick-tcpdf/TCPDF2DBarcode.html
+++ b/doc/com-tecnick-tcpdf/TCPDF2DBarcode.html
@@ -80,7 +80,7 @@ Source Location: /2dbarcodes.php
Version:
@@ -128,7 +128,7 @@ PHP class to creates array representations for 2D barcodes to be used with TCPDF
author: | Nicola Asuni |
- version: | 1.0.005 |
+ version: | 1.0.006 |
link: | http://www.tcpdf.org |
@@ -218,7 +218,7 @@ $type)
string |
$type |
- type of barcode: - RAW: raw mode - comma-separad list of array rows
- RAW2: raw mode - array rows are surrounded by square parenthesis.
- QRCODE : QR-CODE Low error correction
- QRCODE,L : QR-CODE Low error correction
- QRCODE,M : QR-CODE Medium error correction
- QRCODE,Q : QR-CODE Better error correction
- QRCODE,H : QR-CODE Best error correction
- PDF417 : PDF417 (ISO/IEC 15438:2006)
- PDF417,a,e : PDF417 with aspect ratio (a = width/height) and error correction level (e = 0-8)
|
+ type of barcode: - RAW: raw mode - comma-separad list of array rows
- RAW2: raw mode - array rows are surrounded by square parenthesis.
- QRCODE : QR-CODE Low error correction
- QRCODE,L : QR-CODE Low error correction
- QRCODE,M : QR-CODE Medium error correction
- QRCODE,Q : QR-CODE Better error correction
- QRCODE,H : QR-CODE Best error correction
- PDF417 : PDF417 (ISO/IEC 15438:2006)
- 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".
|
@@ -285,7 +285,7 @@ $type)
string |
$type |
- type of barcode: - RAW: raw mode - comma-separad list of array rows
- RAW2: raw mode - array rows are surrounded by square parenthesis.
- QRCODE : QR-CODE Low error correction
- QRCODE,L : QR-CODE Low error correction
- QRCODE,M : QR-CODE Medium error correction
- QRCODE,Q : QR-CODE Better error correction
- QRCODE,H : QR-CODE Best error correction
- PDF417 : PDF417 (ISO/IEC 15438:2006)
- PDF417,a,e : PDF417 with aspect ratio (a = width/height) and error correction level (e = 0-8)
|
+ type of barcode: - RAW: raw mode - comma-separad list of array rows
- RAW2: raw mode - array rows are surrounded by square parenthesis.
- QRCODE : QR-CODE Low error correction
- QRCODE,L : QR-CODE Low error correction
- QRCODE,M : QR-CODE Medium error correction
- QRCODE,Q : QR-CODE Better error correction
- QRCODE,H : QR-CODE Best error correction
- PDF417 : PDF417 (ISO/IEC 15438:2006)
- 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".
|
@@ -296,7 +296,7 @@ $type)
diff --git a/doc/com-tecnick-tcpdf/TCPDFBarcode.html b/doc/com-tecnick-tcpdf/TCPDFBarcode.html
index e11c2b8..28b1fd2 100644
--- a/doc/com-tecnick-tcpdf/TCPDFBarcode.html
+++ b/doc/com-tecnick-tcpdf/TCPDFBarcode.html
@@ -1374,7 +1374,7 @@ $type)
diff --git a/doc/com-tecnick-tcpdf/_2dbarcodes.php.html b/doc/com-tecnick-tcpdf/_2dbarcodes.php.html
index d43ead2..8eac4a3 100644
--- a/doc/com-tecnick-tcpdf/_2dbarcodes.php.html
+++ b/doc/com-tecnick-tcpdf/_2dbarcodes.php.html
@@ -79,7 +79,7 @@ PHP class to creates array representations for 2D barcodes to be used with TCPDF
author: | Nicola Asuni |
- version: | 1.0.005 |
+ version: | 1.0.006 |
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 |
@@ -102,7 +102,7 @@ PHP class to creates array representations for 2D barcodes to be used with TCPDF
diff --git a/doc/com-tecnick-tcpdf/_barcodes.php.html b/doc/com-tecnick-tcpdf/_barcodes.php.html
index 49af9a5..41eaf54 100644
--- a/doc/com-tecnick-tcpdf/_barcodes.php.html
+++ b/doc/com-tecnick-tcpdf/_barcodes.php.html
@@ -102,7 +102,7 @@ PHP class to creates array representations for common 1D barcodes to be used wit
diff --git a/doc/com-tecnick-tcpdf/_config---tcpdf_config.php.html b/doc/com-tecnick-tcpdf/_config---tcpdf_config.php.html
index 0a2cf45..32c7250 100644
--- a/doc/com-tecnick-tcpdf/_config---tcpdf_config.php.html
+++ b/doc/com-tecnick-tcpdf/_config---tcpdf_config.php.html
@@ -539,7 +539,7 @@ Configuration file for TCPDF.
diff --git a/doc/com-tecnick-tcpdf/_htmlcolors.php.html b/doc/com-tecnick-tcpdf/_htmlcolors.php.html
index 5d4e985..b95c70a 100644
--- a/doc/com-tecnick-tcpdf/_htmlcolors.php.html
+++ b/doc/com-tecnick-tcpdf/_htmlcolors.php.html
@@ -94,7 +94,7 @@ Array of WEB safe colors.
diff --git a/doc/com-tecnick-tcpdf/_qrcode.php.html b/doc/com-tecnick-tcpdf/_qrcode.php.html
index f70b08f..90992fa 100644
--- a/doc/com-tecnick-tcpdf/_qrcode.php.html
+++ b/doc/com-tecnick-tcpdf/_qrcode.php.html
@@ -477,7 +477,7 @@ string $string, [int $split_length = 1])
diff --git a/doc/com-tecnick-tcpdf/_tcpdf.php.html b/doc/com-tecnick-tcpdf/_tcpdf.php.html
index ccec853..cbfb573 100644
--- a/doc/com-tecnick-tcpdf/_tcpdf.php.html
+++ b/doc/com-tecnick-tcpdf/_tcpdf.php.html
@@ -121,7 +121,7 @@ unicode data
diff --git a/doc/com-tecnick-tcpdf/_unicode_data.php.html b/doc/com-tecnick-tcpdf/_unicode_data.php.html
index a01e36b..d13b45f 100644
--- a/doc/com-tecnick-tcpdf/_unicode_data.php.html
+++ b/doc/com-tecnick-tcpdf/_unicode_data.php.html
@@ -243,7 +243,7 @@ Unicode data for TCPDF library.
diff --git a/doc/elementindex.html b/doc/elementindex.html
index 2d6cf9d..25b2f65 100644
--- a/doc/elementindex.html
+++ b/doc/elementindex.html
@@ -1976,7 +1976,7 @@
top
diff --git a/doc/elementindex_com-tecnick-tcpdf.html b/doc/elementindex_com-tecnick-tcpdf.html
index d3e1036..bb4ef98 100644
--- a/doc/elementindex_com-tecnick-tcpdf.html
+++ b/doc/elementindex_com-tecnick-tcpdf.html
@@ -2005,7 +2005,7 @@
top
diff --git a/doc/errors.html b/doc/errors.html
index 25e12d5..90f134d 100644
--- a/doc/errors.html
+++ b/doc/errors.html
@@ -35,7 +35,7 @@
Post-parsing
diff --git a/doc/index.html b/doc/index.html
index 32dc86e..c3ceaaa 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -64,7 +64,7 @@
This documentation was generated by phpDocumentor v1.4.3
diff --git a/doc/li_com-tecnick-tcpdf.html b/doc/li_com-tecnick-tcpdf.html
index 32dc86e..c3ceaaa 100644
--- a/doc/li_com-tecnick-tcpdf.html
+++ b/doc/li_com-tecnick-tcpdf.html
@@ -64,7 +64,7 @@
This documentation was generated by phpDocumentor v1.4.3
diff --git a/pdf417.php b/pdf417.php
index 4357853..8e72f41 100644
--- a/pdf417.php
+++ b/pdf417.php
@@ -1,9 +1,9 @@
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;
}