From 03b7a147c51d6fe0e521a67ea3b369d37076670e Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 6 Jun 2010 13:18:48 +0200 Subject: [PATCH] 5.3.001 --- 2dbarcodes.php | 28 ++++++-- doc/classtrees_com-tecnick-tcpdf.html | 2 +- doc/com-tecnick-tcpdf/QRcode.html | 2 +- doc/com-tecnick-tcpdf/TCPDF.html | 2 +- doc/com-tecnick-tcpdf/TCPDF2DBarcode.html | 10 +-- doc/com-tecnick-tcpdf/TCPDFBarcode.html | 2 +- doc/com-tecnick-tcpdf/_2dbarcodes.php.html | 4 +- doc/com-tecnick-tcpdf/_barcodes.php.html | 2 +- .../_config---tcpdf_config.php.html | 2 +- doc/com-tecnick-tcpdf/_htmlcolors.php.html | 2 +- doc/com-tecnick-tcpdf/_qrcode.php.html | 2 +- doc/com-tecnick-tcpdf/_tcpdf.php.html | 2 +- doc/com-tecnick-tcpdf/_unicode_data.php.html | 2 +- doc/elementindex.html | 2 +- doc/elementindex_com-tecnick-tcpdf.html | 2 +- doc/errors.html | 2 +- doc/index.html | 2 +- doc/li_com-tecnick-tcpdf.html | 2 +- pdf417.php | 65 +++++++++++++++---- 19 files changed, 96 insertions(+), 41 deletions(-) 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: + * @param string $type type of barcode: */ 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: + * @param string $type type of barcode: * @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 @@

    - Documentation generated on Sun, 06 Jun 2010 13:13:30 +0200 by phpDocumentor 1.4.3 + Documentation generated on Sun, 06 Jun 2010 13:18:39 +0200 by phpDocumentor 1.4.3
    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)

    - Documentation generated on Sun, 06 Jun 2010 13:13:31 +0200 by phpDocumentor 1.4.3 + Documentation generated on Sun, 06 Jun 2010 13:18:40 +0200 by phpDocumentor 1.4.3
    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)

    - Documentation generated on Sun, 06 Jun 2010 13:13:32 +0200 by phpDocumentor 1.4.3 + Documentation generated on Sun, 06 Jun 2010 13:18:41 +0200 by phpDocumentor 1.4.3
    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: + type of barcode:
    @@ -285,7 +285,7 @@ $type) string   $type   - type of barcode: + type of barcode:
    @@ -296,7 +296,7 @@ $type)

    - Documentation generated on Sun, 06 Jun 2010 13:13:30 +0200 by phpDocumentor 1.4.3 + Documentation generated on Sun, 06 Jun 2010 13:18:39 +0200 by phpDocumentor 1.4.3
    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)

    - Documentation generated on Sun, 06 Jun 2010 13:13:30 +0200 by phpDocumentor 1.4.3 + Documentation generated on Sun, 06 Jun 2010 13:18:39 +0200 by phpDocumentor 1.4.3
    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

    - Documentation generated on Sun, 06 Jun 2010 13:13:30 +0200 by phpDocumentor 1.4.3 + Documentation generated on Sun, 06 Jun 2010 13:18:39 +0200 by phpDocumentor 1.4.3
    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

    - Documentation generated on Sun, 06 Jun 2010 13:13:30 +0200 by phpDocumentor 1.4.3 + Documentation generated on Sun, 06 Jun 2010 13:18:39 +0200 by phpDocumentor 1.4.3
    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.




    - Documentation generated on Sun, 06 Jun 2010 13:13:36 +0200 by phpDocumentor 1.4.3 + Documentation generated on Sun, 06 Jun 2010 13:18:45 +0200 by phpDocumentor 1.4.3
    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.




    - Documentation generated on Sun, 06 Jun 2010 13:13:31 +0200 by phpDocumentor 1.4.3 + Documentation generated on Sun, 06 Jun 2010 13:18:40 +0200 by phpDocumentor 1.4.3
    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])

    - Documentation generated on Sun, 06 Jun 2010 13:13:31 +0200 by phpDocumentor 1.4.3 + Documentation generated on Sun, 06 Jun 2010 13:18:40 +0200 by phpDocumentor 1.4.3
    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


    - Documentation generated on Sun, 06 Jun 2010 13:13:32 +0200 by phpDocumentor 1.4.3 + Documentation generated on Sun, 06 Jun 2010 13:18:41 +0200 by phpDocumentor 1.4.3
    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.




    - Documentation generated on Sun, 06 Jun 2010 13:13:36 +0200 by phpDocumentor 1.4.3 + Documentation generated on Sun, 06 Jun 2010 13:18:45 +0200 by phpDocumentor 1.4.3
    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

    - Documentation generated on Sun, 06 Jun 2010 13:13:30 +0200 by phpDocumentor 1.4.3 + Documentation generated on Sun, 06 Jun 2010 13:18:39 +0200 by phpDocumentor 1.4.3
    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

    - Documentation generated on Sun, 06 Jun 2010 13:13:30 +0200 by phpDocumentor 1.4.3 + Documentation generated on Sun, 06 Jun 2010 13:18:39 +0200 by phpDocumentor 1.4.3
    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

    - Documentation generated on Sun, 06 Jun 2010 13:13:36 +0200 by phpDocumentor 1.4.3 + Documentation generated on Sun, 06 Jun 2010 13:18:45 +0200 by phpDocumentor 1.4.3
    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

    - Documentation generated on Sun, 06 Jun 2010 13:13:30 +0200 by phpDocumentor 1.4.3 + Documentation generated on Sun, 06 Jun 2010 13:18:39 +0200 by phpDocumentor 1.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

    - Documentation generated on Sun, 06 Jun 2010 13:13:30 +0200 by phpDocumentor 1.4.3 + Documentation generated on Sun, 06 Jun 2010 13:18:39 +0200 by phpDocumentor 1.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; }