From: <dai...@us...> - 2014-08-02 05:07:58
|
Revision: 6802 http://sourceforge.net/p/web-erp/reponame/6802 Author: daintree Date: 2014-08-02 05:07:53 +0000 (Sat, 02 Aug 2014) Log Message: ----------- update tcpdf Modified Paths: -------------- trunk/Labels.php trunk/PDFPrintLabel.php trunk/includes/PDFStarter.php trunk/includes/class.pdf.php trunk/includes/tcpdf/README.TXT trunk/includes/tcpdf/tcpdf.php Added Paths: ----------- trunk/includes/tcpdf/include/ trunk/includes/tcpdf/include/sRGB.icc trunk/includes/tcpdf/include/tcpdf_colors.php trunk/includes/tcpdf/include/tcpdf_filters.php trunk/includes/tcpdf/include/tcpdf_font_data.php trunk/includes/tcpdf/include/tcpdf_fonts.php trunk/includes/tcpdf/include/tcpdf_images.php trunk/includes/tcpdf/include/tcpdf_static.php trunk/includes/tcpdf/tcpdf_autoconfig.php Removed Paths: ------------- trunk/includes/tcpdf/2dbarcodes.php trunk/includes/tcpdf/barcodes.php trunk/includes/tcpdf/config/lang/ trunk/includes/tcpdf/encodings_maps.php trunk/includes/tcpdf/htmlcolors.php trunk/includes/tcpdf/tcpdf.pem trunk/includes/tcpdf/unicode_data.php Modified: trunk/Labels.php =================================================================== --- trunk/Labels.php 2014-08-01 21:53:04 UTC (rev 6801) +++ trunk/Labels.php 2014-08-02 05:07:53 UTC (rev 6802) @@ -117,6 +117,10 @@ . '" alt="" />' . $Title . ' - ' . _('all measurements in PDF points') . '</p>'; +if (!function_exists('gd_info')) { + prnMsg(_('The GD module for PHP is required to print barcode labels. Your PHP installation is not capable currently. You will most likely experience problems with this script until the GD module is enabled.'),'error'); +} + if (isset($_POST['SelectedLabelID'])){ $SelectedLabelID =$_POST['SelectedLabelID']; if (ctype_digit($_POST['NoOfFieldsDefined'])){ //Now Process any field updates @@ -236,7 +240,7 @@ $result = DB_query($sql,$db,$ErrMsg); $Message = _('The new label template has been added to the database'); } - + if (isset($InputError) AND $InputError !=1) { unset( $_POST['PaperSize']); unset( $_POST['Description']); @@ -304,8 +308,16 @@ echo '<tr class="OddTableRows">'; $k++; } - $NoOfRows = floor(($myrow['pageheight']-$myrow['topmargin'])/$myrow['rowheight']); - $NoOfCols = floor(($myrow['pagewidth']-$myrow['leftmargin'])/$myrow['columnwidth']); + if ($myrow['rowheight']>0) { + $NoOfRows = floor(($myrow['pageheight']-$myrow['topmargin'])/$myrow['rowheight']); + } else { + $NoOfRows = 0; + } + if ($myrow['columnwidth']>0) { + $NoOfCols = floor(($myrow['pagewidth']-$myrow['leftmargin'])/$myrow['columnwidth']); + } else { + $NoOfCols = 0; + } foreach ($PaperSize as $PaperName=>$PaperType) { if ($PaperType['PageWidth'] == $myrow['pagewidth'] AND $PaperType['PageHeight'] == $myrow['pageheight']) { Modified: trunk/PDFPrintLabel.php =================================================================== --- trunk/PDFPrintLabel.php 2014-08-01 21:53:04 UTC (rev 6801) +++ trunk/PDFPrintLabel.php 2014-08-02 05:07:53 UTC (rev 6802) @@ -6,7 +6,6 @@ $PtsPerMM = 2.83465; //pdf points per mm - if ((isset($_POST['ShowLabels']) OR isset($_POST['SelectAll'])) AND isset($_POST['FromCriteria']) AND mb_strlen($_POST['FromCriteria'])>=1 @@ -117,10 +116,10 @@ include('includes/footer.inc'); exit; } -if (isset($_POST['PrintLabels']) - AND isset($_POST['NoOfLabels']) - AND $_POST['NoOfLabels']>0){ - $NoOfLabels = 0; + +$NoOfLabels = 0; +if (isset($_POST['PrintLabels']) AND isset($_POST['NoOfLabels']) AND $_POST['NoOfLabels']>0){ + for ($i=0;$i < $_POST['NoOfLabels'];$i++){ if (isset($_POST['PrintLabel'.$i])){ $NoOfLabels++; @@ -271,16 +270,21 @@ echo '<p class="page_title_text"><img src="' . $RootPath . '/css/' . $Theme . '/images/customer.png" title="' . _('Price Labels') . '" alt="" /> ' . ' ' . _('Print Price Labels') . '</p>'; + if (!function_exists('gd_info')) { + prnMsg(_('The GD module for PHP is required to print barcode labels. Your PHP installation is not capable currently. You will most likely experience problems with this script until the GD module is enabled.'),'error'); + } + + if (!isset($_POST['FromCriteria']) OR !isset($_POST['ToCriteria'])) { /*if $FromCriteria is not set then show a form to allow input */ - echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">'; - echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - echo '<table class="selection">'; - echo '<tr> - <td>' . _('Label to print') . ':</td> - <td><select required="required" autofocus="autofocus" name="LabelID">'; + echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post"> + <input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" /> + <table class="selection"> + <tr> + <td>' . _('Label to print') . ':</td> + <td><select required="required" autofocus="autofocus" name="LabelID">'; $LabelResult = DB_query("SELECT labelid, description FROM labels",$db); while ($LabelRow = DB_fetch_array($LabelResult)){ Modified: trunk/includes/PDFStarter.php =================================================================== --- trunk/includes/PDFStarter.php 2014-08-01 21:53:04 UTC (rev 6801) +++ trunk/includes/PDFStarter.php 2014-08-02 05:07:53 UTC (rev 6802) @@ -181,18 +181,18 @@ // $PageSize = array(0,0,$Page_Width,$Page_Height); // $pdf = new Cpdf($PageSize); $pdf = new Cpdf($DocumentOrientation, 'pt', $DocumentPaper); -$pdf->addInfo('Creator', 'WebERP http://www.weberp.org'); +$pdf->addInfo('Creator', 'webERP http://www.weberp.org'); $pdf->addInfo('Author', 'WebERP ' . $Version); /* Javier: I have brought this piece from the pdf class constructor to get it closer to the admin/user, I corrected it to match TCPDF, but it still needs check, after which, I think it should be moved to each report to provide flexible Document Header and Margins in a per-report basis. */ - $pdf->SetPrintHeader(false); // Javier: I added this must be called before Add Page - $pdf->setAutoPageBreak(0); - $pdf->setPrintFooter(false); - $pdf->AddPage(); - $pdf->cMargin = 0; +$pdf->SetPrintHeader(false); // Javier: I added this must be called before Add Page +$pdf->setAutoPageBreak(0); +$pdf->setPrintFooter(false); +$pdf->AddPage(); +$pdf->cMargin = 0; /* END Brought from class.pdf.php constructor */ ?> Modified: trunk/includes/class.pdf.php =================================================================== --- trunk/includes/class.pdf.php 2014-08-01 21:53:04 UTC (rev 6801) +++ trunk/includes/class.pdf.php 2014-08-02 05:07:53 UTC (rev 6802) @@ -13,7 +13,6 @@ Work to move from FPDF to TCPDF by: Javier de Lorenzo-Cáceres <in...@ci...> ----------------------------------------------------------------------------------------------- */ -require_once(dirname(__FILE__).'/tcpdf/config/lang/eng.php'); require_once(dirname(__FILE__).'/tcpdf/tcpdf.php'); if (!class_exists('Cpdf', false)) { Deleted: trunk/includes/tcpdf/2dbarcodes.php =================================================================== --- trunk/includes/tcpdf/2dbarcodes.php 2014-08-01 21:53:04 UTC (rev 6801) +++ trunk/includes/tcpdf/2dbarcodes.php 2014-08-02 05:07:53 UTC (rev 6802) @@ -1,332 +0,0 @@ -<?php -//============================================================+ -// File name : 2dbarcodes.php -// Version : 1.0.014 -// Begin : 2009-04-07 -// Last Update : 2012-04-30 -// Author : Nicola Asuni - Tecnick.com LTD - Manor Coach House, Church Hill, Aldershot, Hants, GU12 4RQ, UK - www.tecnick.com - in...@te... -// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) -// ------------------------------------------------------------------- -// Copyright (C) 2009-2012 Nicola Asuni - Tecnick.com LTD -// -// This file is part of TCPDF software library. -// -// TCPDF is free software: you can redistribute it and/or modify it -// under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// TCPDF is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with TCPDF. If not, see <http://www.gnu.org/licenses/>. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : PHP class to creates array representations for -// 2D barcodes to be used with TCPDF. -// -//============================================================+ - -/** - * @file - * PHP class to creates array representations for 2D barcodes to be used with TCPDF. - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.014 - */ - -/** - * @class TCPDF2DBarcode - * PHP class to creates array representations for 2D barcodes to be used with TCPDF (http://www.tcpdf.org). - * @package com.tecnick.tcpdf - * @version 1.0.014 - * @author Nicola Asuni - */ -class TCPDF2DBarcode { - - /** - * Array representation of barcode. - * @protected - */ - protected $barcode_array = false; - - /** - * This is the class constructor. - * Return an array representations for 2D barcodes:<ul> - * <li>$arrcode['code'] code to be printed on text label</li> - * <li>$arrcode['num_rows'] required number of rows</li> - * <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 $code (string) code to print - * @param $type (string) type of barcode: <ul><li>DATAMATRIX : Datamatrix (ISO/IEC 16022)</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><li>QRCODE : QRcode Low error correction</li><li>QRCODE,L : QRcode Low error correction</li><li>QRCODE,M : QRcode Medium error correction</li><li>QRCODE,Q : QRcode Better error correction</li><li>QRCODE,H : QR-CODE Best error correction</li><li>RAW: raw mode - comma-separad list of array rows</li><li>RAW2: raw mode - array rows are surrounded by square parenthesis.</li><li>TEST : Test matrix</li></ul> - */ - public function __construct($code, $type) { - $this->setBarcode($code, $type); - } - - /** - * Return an array representations of barcode. - * @return array - */ - public function getBarcodeArray() { - return $this->barcode_array; - } - - /** - * Send barcode as SVG image object to the standard output. - * @param $w (int) Width of a single rectangle element in user units. - * @param $h (int) Height of a single rectangle element in user units. - * @param $color (string) Foreground color (in SVG format) for bar elements (background is transparent). - * @public - */ - public function getBarcodeSVG($w=3, $h=3, $color='black') { - // send headers - $code = $this->getBarcodeSVGcode($w, $h, $color); - header('Content-Type: application/svg+xml'); - header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1 - header('Pragma: public'); - header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past - header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - header('Content-Disposition: inline; filename="'.md5($code).'.svg";'); - //header('Content-Length: '.strlen($code)); - echo $code; - } - - /** - * Return a SVG string representation of barcode. - * @param $w (int) Width of a single rectangle element in user units. - * @param $h (int) Height of a single rectangle element in user units. - * @param $color (string) Foreground color (in SVG format) for bar elements (background is transparent). - * @return string SVG code. - * @public - */ - public function getBarcodeSVGcode($w=3, $h=3, $color='black') { - // replace table for special characters - $repstr = array("\0" => '', '&' => '&', '<' => '<', '>' => '>'); - $svg = '<'.'?'.'xml version="1.0" standalone="no"'.'?'.'>'."\n"; - $svg .= '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'."\n"; - $svg .= '<svg width="'.round(($this->barcode_array['num_cols'] * $w), 3).'" height="'.round(($this->barcode_array['num_rows'] * $h), 3).'" version="1.1" xmlns="http://www.w3.org/2000/svg">'."\n"; - $svg .= "\t".'<desc>'.strtr($this->barcode_array['code'], $repstr).'</desc>'."\n"; - $svg .= "\t".'<g id="elements" fill="'.$color.'" stroke="none">'."\n"; - // print barcode elements - $y = 0; - // for each row - for ($r = 0; $r < $this->barcode_array['num_rows']; ++$r) { - $x = 0; - // for each column - for ($c = 0; $c < $this->barcode_array['num_cols']; ++$c) { - if ($this->barcode_array['bcode'][$r][$c] == 1) { - // draw a single barcode cell - $svg .= "\t\t".'<rect x="'.$x.'" y="'.$y.'" width="'.$w.'" height="'.$h.'" />'."\n"; - } - $x += $w; - } - $y += $h; - } - $svg .= "\t".'</g>'."\n"; - $svg .= '</svg>'."\n"; - return $svg; - } - - /** - * Return an HTML representation of barcode. - * @param $w (int) Width of a single rectangle element in pixels. - * @param $h (int) Height of a single rectangle element in pixels. - * @param $color (string) Foreground color for bar elements (background is transparent). - * @return string HTML code. - * @public - */ - public function getBarcodeHTML($w=10, $h=10, $color='black') { - $html = '<div style="font-size:0;position:relative;width:'.($w * $this->barcode_array['num_cols']).'px;height:'.($h * $this->barcode_array['num_rows']).'px;">'."\n"; - // print barcode elements - $y = 0; - // for each row - for ($r = 0; $r < $this->barcode_array['num_rows']; ++$r) { - $x = 0; - // for each column - for ($c = 0; $c < $this->barcode_array['num_cols']; ++$c) { - if ($this->barcode_array['bcode'][$r][$c] == 1) { - // draw a single barcode cell - $html .= '<div style="background-color:'.$color.';width:'.$w.'px;height:'.$h.'px;position:absolute;left:'.$x.'px;top:'.$y.'px;"> </div>'."\n"; - } - $x += $w; - } - $y += $h; - } - $html .= '</div>'."\n"; - return $html; - } - - /** - * Return a PNG image representation of barcode (requires GD or Imagick library). - * @param $w (int) Width of a single rectangle element in pixels. - * @param $h (int) Height of a single rectangle element in pixels. - * @param $color (array) RGB (0-255) foreground color for bar elements (background is transparent). - * @return image or false in case of error. - * @public - */ - public function getBarcodePNG($w=3, $h=3, $color=array(0,0,0)) { - // calculate image size - $width = ($this->barcode_array['num_cols'] * $w); - $height = ($this->barcode_array['num_rows'] * $h); - if (function_exists('imagecreate')) { - // GD library - $imagick = false; - $png = imagecreate($width, $height); - $bgcol = imagecolorallocate($png, 255, 255, 255); - imagecolortransparent($png, $bgcol); - $fgcol = imagecolorallocate($png, $color[0], $color[1], $color[2]); - } elseif (extension_loaded('imagick')) { - $imagick = true; - $bgcol = new imagickpixel('rgb(255,255,255'); - $fgcol = new imagickpixel('rgb('.$color[0].','.$color[1].','.$color[2].')'); - $png = new Imagick(); - $png->newImage($width, $height, 'none', 'png'); - $bar = new imagickdraw(); - $bar->setfillcolor($fgcol); - } else { - return false; - } - // print barcode elements - $y = 0; - // for each row - for ($r = 0; $r < $this->barcode_array['num_rows']; ++$r) { - $x = 0; - // for each column - for ($c = 0; $c < $this->barcode_array['num_cols']; ++$c) { - if ($this->barcode_array['bcode'][$r][$c] == 1) { - // draw a single barcode cell - if ($imagick) { - $bar->rectangle($x, $y, ($x + $w - 1), ($y + $h - 1)); - } else { - imagefilledrectangle($png, $x, $y, ($x + $w - 1), ($y + $h - 1), $fgcol); - } - } - $x += $w; - } - $y += $h; - } - // send headers - header('Content-Type: image/png'); - header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1 - header('Pragma: public'); - header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past - header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - if ($imagick) { - $png->drawimage($bar); - echo $png; - } else { - imagepng($png); - imagedestroy($png); - } - } - - /** - * Set the barcode. - * @param $code (string) code to print - * @param $type (string) type of barcode: <ul><li>DATAMATRIX : Datamatrix (ISO/IEC 16022)</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><li>QRCODE : QRcode Low error correction</li><li>QRCODE,L : QRcode Low error correction</li><li>QRCODE,M : QRcode Medium error correction</li><li>QRCODE,Q : QRcode Better error correction</li><li>QRCODE,H : QR-CODE Best error correction</li><li>RAW: raw mode - comma-separad list of array rows</li><li>RAW2: raw mode - array rows are surrounded by square parenthesis.</li><li>TEST : Test matrix</li></ul> - * @return array - */ - public function setBarcode($code, $type) { - $mode = explode(',', $type); - $qrtype = strtoupper($mode[0]); - switch ($qrtype) { - case 'DATAMATRIX': { // DATAMATRIX (ISO/IEC 16022) - require_once(dirname(__FILE__).'/datamatrix.php'); - $qrcode = new Datamatrix($code); - $this->barcode_array = $qrcode->getBarcodeArray(); - $this->barcode_array['code'] = $code; - break; - } - case 'PDF417': { // PDF417 (ISO/IEC 15438:2006) - require_once(dirname(__FILE__).'/pdf417.php'); - if (!isset($mode[1]) OR ($mode[1] === '')) { - $aspectratio = 2; // default aspect ratio (width / height) - } else { - $aspectratio = floatval($mode[1]); - } - if (!isset($mode[2]) OR ($mode[2] === '')) { - $ecl = -1; // default error correction level (auto) - } else { - $ecl = intval($mode[2]); - } - // 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(); - $this->barcode_array['code'] = $code; - break; - } - case 'QRCODE': { // QR-CODE - require_once(dirname(__FILE__).'/qrcode.php'); - if (!isset($mode[1]) OR (!in_array($mode[1],array('L','M','Q','H')))) { - $mode[1] = 'L'; // Ddefault: Low error correction - } - $qrcode = new QRcode($code, strtoupper($mode[1])); - $this->barcode_array = $qrcode->getBarcodeArray(); - $this->barcode_array['code'] = $code; - break; - } - case 'RAW': - case 'RAW2': { // RAW MODE - // remove spaces - $code = preg_replace('/[\s]*/si', '', $code); - if (strlen($code) < 3) { - break; - } - if ($qrtype == 'RAW') { - // comma-separated rows - $rows = explode(',', $code); - } else { // RAW2 - // rows enclosed in square parentheses - $code = substr($code, 1, -1); - $rows = explode('][', $code); - } - $this->barcode_array['num_rows'] = count($rows); - $this->barcode_array['num_cols'] = strlen($rows[0]); - $this->barcode_array['bcode'] = array(); - foreach ($rows as $r) { - $this->barcode_array['bcode'][] = str_split($r, 1); - } - $this->barcode_array['code'] = $code; - break; - } - case 'TEST': { // TEST MODE - $this->barcode_array['num_rows'] = 5; - $this->barcode_array['num_cols'] = 15; - $this->barcode_array['bcode'] = array( - array(1,1,1,0,1,1,1,0,1,1,1,0,1,1,1), - array(0,1,0,0,1,0,0,0,1,0,0,0,0,1,0), - array(0,1,0,0,1,1,0,0,1,1,1,0,0,1,0), - array(0,1,0,0,1,0,0,0,0,0,1,0,0,1,0), - array(0,1,0,0,1,1,1,0,1,1,1,0,0,1,0)); - $this->barcode_array['code'] = $code; - break; - } - default: { - $this->barcode_array = false; - } - } - } -} // end of class - -//============================================================+ -// END OF FILE -//============================================================+ Modified: trunk/includes/tcpdf/README.TXT =================================================================== --- trunk/includes/tcpdf/README.TXT 2014-08-01 21:53:04 UTC (rev 6801) +++ trunk/includes/tcpdf/README.TXT 2014-08-02 05:07:53 UTC (rev 6802) @@ -8,24 +8,23 @@ ------------------------------------------------------------ Name: TCPDF -Version: 5.9.161 -Release date: 2012-05-09 +Version: 6.0.089 +Release date: 2014-07-16 Author: Nicola Asuni -Copyright (c) 2002-2012: +Copyright (c) 2002-2014: Nicola Asuni Tecnick.com LTD - Manor Coach House, Church Hill - Aldershot, Hants, GU12 4RQ - UK www.tecnick.com URLs: - http: www.tcpdf.org - http: www.sourceforge.net/projects/tcpdf + http://www.tcpdf.org + http://www.sourceforge.net/projects/tcpdf Description: TCPDF is a PHP class for generating PDF files on-the-fly without requiring external extensions. + This library includes also a class to extract data from existing PDF documents and + classes to generate 1D and 2D barcodes in various formats. Main Features: * no external libraries are required for the basic functions; @@ -47,7 +46,7 @@ * no-write page regions; * bookmarks, named destinations and table of content; * text hyphenation; - * text stretching and spacing (tracking/kerning); + * text stretching and spacing (tracking); * automatic page break, line break and text alignments including justification; * automatic page numbering and page groups; * move and delete pages; @@ -67,8 +66,8 @@ Additional Documentation: http://www.tcpdf.org -License - Copyright (C) 2002-2012 Nicola Asuni - Tecnick.com LTD +License: + Copyright (C) 2002-2014 Nicola Asuni - Tecnick.com LTD TCPDF is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -86,12 +85,27 @@ See LICENSE.TXT file for more information. -Third party fonts - This library includes third party font files released with different licenses. - These fonts are not required by TCPDF but have been included as you convenience. - The original TTF font files have been renamed for compatibility with TCPDF and compressed using the gzcompress PHP function that uses the ZLIB data format (.z files). - To get the original distribution archives please check the information on fonts subfolders: - - DejaVu fonts 2.33 (Bitstream) - Copyright, License and other info: fonts/dejavu-fonts-ttf-2.33 - - GNU FreeFont (GNU-GPLv3) - Copyright, License and other info: fonts/freefont-20100919 +Third party fonts: + This library may include third party font files released with different licenses. + + All the PHP files on the fonts directory are subject to the general TCPDF license (GNU-LGPLv3), + they do not contain any binary data but just a description of the general properties of a particular font. + These files can be also generated on the fly using the font utilities and TCPDF methods. + + All the original binary TTF font files have been renamed for compatibility with TCPDF and compressed using the gzcompress PHP function that uses the ZLIB data format (.z files). + + The binary files (.z) that begins with the prefix "free" have been extracted from the GNU FreeFont collection (GNU-GPLv3). + The binary files (.z) that begins with the prefix "pdfa" have been derived from the GNU FreeFont, so they are subject to the same license. + For the details of Copyright, License and other information, please check the files inside the directory fonts/freefont-20120503 + Link : http://www.gnu.org/software/freefont/ + + The binary files (.z) that begins with the prefix "dejavu" have been extracted from the DejaVu fonts 2.33 (Bitstream) collection. + For the details of Copyright, License and other information, please check the files inside the directory fonts/dejavu-fonts-ttf-2.33 + Link : http://dejavu-fonts.org + + The binary files (.z) that begins with the prefix "ae" have been extracted from the Arabeyes.org collection (GNU-GPLv2). + Link : http://projects.arabeyes.org/ + + ============================================================ Deleted: trunk/includes/tcpdf/barcodes.php =================================================================== --- trunk/includes/tcpdf/barcodes.php 2014-08-01 21:53:04 UTC (rev 6801) +++ trunk/includes/tcpdf/barcodes.php 2014-08-02 05:07:53 UTC (rev 6802) @@ -1,2287 +0,0 @@ -<?php -//============================================================+ -// File name : barcodes.php -// Version : 1.0.024 -// Begin : 2008-06-09 -// Last Update : 2012-04-30 -// Author : Nicola Asuni - Tecnick.com LTD - Manor Coach House, Church Hill, Aldershot, Hants, GU12 4RQ, UK - www.tecnick.com - in...@te... -// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) -// ------------------------------------------------------------------- -// Copyright (C) 2008-2012 Nicola Asuni - Tecnick.com LTD -// -// This file is part of TCPDF software library. -// -// TCPDF is free software: you can redistribute it and/or modify it -// under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// TCPDF is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with TCPDF. If not, see <http://www.gnu.org/licenses/>. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : PHP class to creates array representations for -// common 1D barcodes to be used with TCPDF. -// -//============================================================+ - -/** - * @file - * PHP class to creates array representations for common 1D barcodes to be used with TCPDF. - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.024 - */ - -/** - * @class TCPDFBarcode - * PHP class to creates array representations for common 1D barcodes to be used with TCPDF (http://www.tcpdf.org).<br> - * @package com.tecnick.tcpdf - * @version 1.0.024 - * @author Nicola Asuni - */ -class TCPDFBarcode { - - /** - * Array representation of barcode. - * @protected - */ - protected $barcode_array; - - /** - * This is the class constructor. - * Return an array representations for common 1D barcodes:<ul> - * <li>$arrcode['code'] code to be printed on text label</li> - * <li>$arrcode['maxh'] max barcode height</li> - * <li>$arrcode['maxw'] max barcode width</li> - * <li>$arrcode['bcode'][$k] single bar or space in $k position</li> - * <li>$arrcode['bcode'][$k]['t'] bar type: true = bar, false = space.</li> - * <li>$arrcode['bcode'][$k]['w'] bar width in units.</li> - * <li>$arrcode['bcode'][$k]['h'] bar height in units.</li> - * <li>$arrcode['bcode'][$k]['p'] bar top position (0 = top, 1 = middle)</li></ul> - * @param $code (string) code to print - * @param $type (string) type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128 : CODE 128</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extention</li><li>EAN5 : 5-Digits UPC-Based Extention</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul> - * @public - */ - public function __construct($code, $type) { - $this->setBarcode($code, $type); - } - - /** - * Return an array representations of barcode. - * @return array - * @public - */ - public function getBarcodeArray() { - return $this->barcode_array; - } - - /** - * Send barcode as SVG image object to the standard output. - * @param $w (int) Minimum width of a single bar in user units. - * @param $h (int) Height of barcode in user units. - * @param $color (string) Foreground color (in SVG format) for bar elements (background is transparent). - * @public - */ - public function getBarcodeSVG($w=2, $h=30, $color='black') { - // send headers - $code = $this->getBarcodeSVGcode($w, $h, $color); - header('Content-Type: application/svg+xml'); - header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1 - header('Pragma: public'); - header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past - header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - header('Content-Disposition: inline; filename="'.md5($code).'.svg";'); - //header('Content-Length: '.strlen($code)); - echo $code; - } - - /** - * Return a SVG string representation of barcode. - * @param $w (int) Minimum width of a single bar in user units. - * @param $h (int) Height of barcode in user units. - * @param $color (string) Foreground color (in SVG format) for bar elements (background is transparent). - * @return string SVG code. - * @public - */ - public function getBarcodeSVGcode($w=2, $h=30, $color='black') { - // replace table for special characters - $repstr = array("\0" => '', '&' => '&', '<' => '<', '>' => '>'); - $svg = '<'.'?'.'xml version="1.0" standalone="no"'.'?'.'>'."\n"; - $svg .= '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'."\n"; - $svg .= '<svg width="'.round(($this->barcode_array['maxw'] * $w), 3).'" height="'.$h.'" version="1.1" xmlns="http://www.w3.org/2000/svg">'."\n"; - $svg .= "\t".'<desc>'.strtr($this->barcode_array['code'], $repstr).'</desc>'."\n"; - $svg .= "\t".'<g id="bars" fill="'.$color.'" stroke="none">'."\n"; - // print bars - $x = 0; - foreach ($this->barcode_array['bcode'] as $k => $v) { - $bw = round(($v['w'] * $w), 3); - $bh = round(($v['h'] * $h / $this->barcode_array['maxh']), 3); - if ($v['t']) { - $y = round(($v['p'] * $h / $this->barcode_array['maxh']), 3); - // draw a vertical bar - $svg .= "\t\t".'<rect x="'.$x.'" y="'.$y.'" width="'.$bw.'" height="'.$bh.'" />'."\n"; - } - $x += $bw; - } - $svg .= "\t".'</g>'."\n"; - $svg .= '</svg>'."\n"; - return $svg; - } - - /** - * Return an HTML representation of barcode. - * @param $w (int) Width of a single bar element in pixels. - * @param $h (int) Height of a single bar element in pixels. - * @param $color (string) Foreground color for bar elements (background is transparent). - * @return string HTML code. - * @public - */ - public function getBarcodeHTML($w=2, $h=30, $color='black') { - $html = '<div style="font-size:0;position:relative;width:'.($this->barcode_array['maxw'] * $w).'px;height:'.($h).'px;">'."\n"; - // print bars - $x = 0; - foreach ($this->barcode_array['bcode'] as $k => $v) { - $bw = round(($v['w'] * $w), 3); - $bh = round(($v['h'] * $h / $this->barcode_array['maxh']), 3); - if ($v['t']) { - $y = round(($v['p'] * $h / $this->barcode_array['maxh']), 3); - // draw a vertical bar - $html .= '<div style="background-color:'.$color.';width:'.$bw.'px;height:'.$bh.'px;position:absolute;left:'.$x.'px;top:'.$y.'px;"> </div>'."\n"; - } - $x += $bw; - } - $html .= '</div>'."\n"; - return $html; - } - - /** - * Return a PNG image representation of barcode (requires GD or Imagick library). - * @param $w (int) Width of a single bar element in pixels. - * @param $h (int) Height of a single bar element in pixels. - * @param $color (array) RGB (0-255) foreground color for bar elements (background is transparent). - * @return image or false in case of error. - * @public - */ - public function getBarcodePNG($w=2, $h=30, $color=array(0,0,0)) { - // calculate image size - $width = ($this->barcode_array['maxw'] * $w); - $height = $h; - if (function_exists('imagecreate')) { - // GD library - $imagick = false; - $png = imagecreate($width, $height); - $bgcol = imagecolorallocate($png, 255, 255, 255); - imagecolortransparent($png, $bgcol); - $fgcol = imagecolorallocate($png, $color[0], $color[1], $color[2]); - } elseif (extension_loaded('imagick')) { - $imagick = true; - $bgcol = new imagickpixel('rgb(255,255,255'); - $fgcol = new imagickpixel('rgb('.$color[0].','.$color[1].','.$color[2].')'); - $png = new Imagick(); - $png->newImage($width, $height, 'none', 'png'); - $bar = new imagickdraw(); - $bar->setfillcolor($fgcol); - } else { - return false; - } - // print bars - $x = 0; - foreach ($this->barcode_array['bcode'] as $k => $v) { - $bw = round(($v['w'] * $w), 3); - $bh = round(($v['h'] * $h / $this->barcode_array['maxh']), 3); - if ($v['t']) { - $y = round(($v['p'] * $h / $this->barcode_array['maxh']), 3); - // draw a vertical bar - if ($imagick) { - $bar->rectangle($x, $y, ($x + $bw - 1), ($y + $bh - 1)); - } else { - imagefilledrectangle($png, $x, $y, ($x + $bw - 1), ($y + $bh - 1), $fgcol); - } - } - $x += $bw; - } - // send headers - header('Content-Type: image/png'); - header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1 - header('Pragma: public'); - header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past - header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - if ($imagick) { - $png->drawimage($bar); - echo $png; - } else { - imagepng($png); - imagedestroy($png); - } - } - - /** - * Set the barcode. - * @param $code (string) code to print - * @param $type (string) type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128 : CODE 128</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extention</li><li>EAN5 : 5-Digits UPC-Based Extention</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul> - * @return array barcode array - * @public - */ - public function setBarcode($code, $type) { - switch (strtoupper($type)) { - case 'C39': { // CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9. - $arrcode = $this->barcode_code39($code, false, false); - break; - } - case 'C39+': { // CODE 39 with checksum - $arrcode = $this->barcode_code39($code, false, true); - break; - } - case 'C39E': { // CODE 39 EXTENDED - $arrcode = $this->barcode_code39($code, true, false); - break; - } - case 'C39E+': { // CODE 39 EXTENDED + CHECKSUM - $arrcode = $this->barcode_code39($code, true, true); - break; - } - case 'C93': { // CODE 93 - USS-93 - $arrcode = $this->barcode_code93($code); - break; - } - case 'S25': { // Standard 2 of 5 - $arrcode = $this->barcode_s25($code, false); - break; - } - case 'S25+': { // Standard 2 of 5 + CHECKSUM - $arrcode = $this->barcode_s25($code, true); - break; - } - case 'I25': { // Interleaved 2 of 5 - $arrcode = $this->barcode_i25($code, false); - break; - } - case 'I25+': { // Interleaved 2 of 5 + CHECKSUM - $arrcode = $this->barcode_i25($code, true); - break; - } - case 'C128': { // CODE 128 - $arrcode = $this->barcode_c128($code, ''); - break; - } - case 'C128A': { // CODE 128 A - $arrcode = $this->barcode_c128($code, 'A'); - break; - } - case 'C128B': { // CODE 128 B - $arrcode = $this->barcode_c128($code, 'B'); - break; - } - case 'C128C': { // CODE 128 C - $arrcode = $this->barcode_c128($code, 'C'); - break; - } - case 'EAN2': { // 2-Digits UPC-Based Extention - $arrcode = $this->barcode_eanext($code, 2); - break; - } - case 'EAN5': { // 5-Digits UPC-Based Extention - $arrcode = $this->barcode_eanext($code, 5); - break; - } - case 'EAN8': { // EAN 8 - $arrcode = $this->barcode_eanupc($code, 8); - break; - } - case 'EAN13': { // EAN 13 - $arrcode = $this->barcode_eanupc($code, 13); - break; - } - case 'UPCA': { // UPC-A - $arrcode = $this->barcode_eanupc($code, 12); - break; - } - case 'UPCE': { // UPC-E - $arrcode = $this->barcode_eanupc($code, 6); - break; - } - case 'MSI': { // MSI (Variation of Plessey code) - $arrcode = $this->barcode_msi($code, false); - break; - } - case 'MSI+': { // MSI + CHECKSUM (modulo 11) - $arrcode = $this->barcode_msi($code, true); - break; - } - case 'POSTNET': { // POSTNET - $arrcode = $this->barcode_postnet($code, false); - break; - } - case 'PLANET': { // PLANET - $arrcode = $this->barcode_postnet($code, true); - break; - } - case 'RMS4CC': { // RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code) - $arrcode = $this->barcode_rms4cc($code, false); - break; - } - case 'KIX': { // KIX (Klant index - Customer index) - $arrcode = $this->barcode_rms4cc($code, true); - break; - } - case 'IMB': { // IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200 - $arrcode = $this->barcode_imb($code); - break; - } - case 'CODABAR': { // CODABAR - $arrcode = $this->barcode_codabar($code); - break; - } - case 'CODE11': { // CODE 11 - $arrcode = $this->barcode_code11($code); - break; - } - case 'PHARMA': { // PHARMACODE - $arrcode = $this->barcode_pharmacode($code); - break; - } - case 'PHARMA2T': { // PHARMACODE TWO-TRACKS - $arrcode = $this->barcode_pharmacode2t($code); - break; - } - default: { - $this->barcode_array = false; - $arrcode = false; - break; - } - } - $this->barcode_array = $arrcode; - } - - /** - * CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9. - * General-purpose code in very wide use world-wide - * @param $code (string) code to represent. - * @param $extended (boolean) if true uses the extended mode. - * @param $checksum (boolean) if true add a checksum to the code. - * @return array barcode representation. - * @protected - */ - protected function barcode_code39($code, $extended=false, $checksum=false) { - $chr['0'] = '111331311'; - $chr['1'] = '311311113'; - $chr['2'] = '113311113'; - $chr['3'] = '313311111'; - $chr['4'] = '111331113'; - $chr['5'] = '311331111'; - $chr['6'] = '113331111'; - $chr['7'] = '111311313'; - $chr['8'] = '311311311'; - $chr['9'] = '113311311'; - $chr['A'] = '311113113'; - $chr['B'] = '113113113'; - $chr['C'] = '313113111'; - $chr['D'] = '111133113'; - $chr['E'] = '311133111'; - $chr['F'] = '113133111'; - $chr['G'] = '111113313'; - $chr['H'] = '311113311'; - $chr['I'] = '113113311'; - $chr['J'] = '111133311'; - $chr['K'] = '311111133'; - $chr['L'] = '113111133'; - $chr['M'] = '313111131'; - $chr['N'] = '111131133'; - $chr['O'] = '311131131'; - $chr['P'] = '113131131'; - $chr['Q'] = '111111333'; - $chr['R'] = '311111331'; - $chr['S'] = '113111331'; - $chr['T'] = '111131331'; - $chr['U'] = '331111113'; - $chr['V'] = '133111113'; - $chr['W'] = '333111111'; - $chr['X'] = '131131113'; - $chr['Y'] = '331131111'; - $chr['Z'] = '133131111'; - $chr['-'] = '131111313'; - $chr['.'] = '331111311'; - $chr[' '] = '133111311'; - $chr['$'] = '131313111'; - $chr['/'] = '131311131'; - $chr['+'] = '131113131'; - $chr['%'] = '111313131'; - $chr['*'] = '131131311'; - $code = strtoupper($code); - if ($extended) { - // extended mode - $code = $this->encode_code39_ext($code); - } - if ($code === false) { - return false; - } - if ($checksum) { - // checksum - $code .= $this->checksum_code39($code); - } - // add start and stop codes - $code = '*'.$code.'*'; - $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); - $k = 0; - $clen = strlen($code); - for ($i = 0; $i < $clen; ++$i) { - $char = $code{$i}; - if(!isset($chr[$char])) { - // invalid character - return false; - } - for ($j = 0; $j < 9; ++$j) { - if (($j % 2) == 0) { - $t = true; // bar - } else { - $t = false; // space - } - $w = $chr[$char]{$j}; - $bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0); - $bararray['maxw'] += $w; - ++$k; - } - // intercharacter gap - $bararray['bcode'][$k] = array('t' => false, 'w' => 1, 'h' => 1, 'p' => 0); - $bararray['maxw'] += 1; - ++$k; - } - return $bararray; - } - - /** - * Encode a string to be used for CODE 39 Extended mode. - * @param $code (string) code to represent. - * @return encoded string. - * @protected - */ - protected function encode_code39_ext($code) { - $encode = array( - chr(0) => '%U', chr(1) => '$A', chr(2) => '$B', chr(3) => '$C', - chr(4) => '$D', chr(5) => '$E', chr(6) => '$F', chr(7) => '$G', - chr(8) => '$H', chr(9) => '$I', chr(10) => '$J', chr(11) => '£K', - chr(12) => '$L', chr(13) => '$M', chr(14) => '$N', chr(15) => '$O', - chr(16) => '$P', chr(17) => '$Q', chr(18) => '$R', chr(19) => '$S', - chr(20) => '$T', chr(21) => '$U', chr(22) => '$V', chr(23) => '$W', - chr(24) => '$X', chr(25) => '$Y', chr(26) => '$Z', chr(27) => '%A', - chr(28) => '%B', chr(29) => '%C', chr(30) => '%D', chr(31) => '%E', - chr(32) => ' ', chr(33) => '/A', chr(34) => '/B', chr(35) => '/C', - chr(36) => '/D', chr(37) => '/E', chr(38) => '/F', chr(39) => '/G', - chr(40) => '/H', chr(41) => '/I', chr(42) => '/J', chr(43) => '/K', - chr(44) => '/L', chr(45) => '-', chr(46) => '.', chr(47) => '/O', - chr(48) => '0', chr(49) => '1', chr(50) => '2', chr(51) => '3', - chr(52) => '4', chr(53) => '5', chr(54) => '6', chr(55) => '7', - chr(56) => '8', chr(57) => '9', chr(58) => '/Z', chr(59) => '%F', - chr(60) => '%G', chr(61) => '%H', chr(62) => '%I', chr(63) => '%J', - chr(64) => '%V', chr(65) => 'A', chr(66) => 'B', chr(67) => 'C', - chr(68) => 'D', chr(69) => 'E', chr(70) => 'F', chr(71) => 'G', - chr(72) => 'H', chr(73) => 'I', chr(74) => 'J', chr(75) => 'K', - chr(76) => 'L', chr(77) => 'M', chr(78) => 'N', chr(79) => 'O', - chr(80) => 'P', chr(81) => 'Q', chr(82) => 'R', chr(83) => 'S', - chr(84) => 'T', chr(85) => 'U', chr(86) => 'V', chr(87) => 'W', - chr(88) => 'X', chr(89) => 'Y', chr(90) => 'Z', chr(91) => '%K', - chr(92) => '%L', chr(93) => '%M', chr(94) => '%N', chr(95) => '%O', - chr(96) => '%W', chr(97) => '+A', chr(98) => '+B', chr(99) => '+C', - chr(100) => '+D', chr(101) => '+E', chr(102) => '+F', chr(103) => '+G', - chr(104) => '+H', chr(105) => '+I', chr(106) => '+J', chr(107) => '+K', - chr(108) => '+L', chr(109) => '+M', chr(110) => '+N', chr(111) => '+O', - chr(112) => '+P', chr(113) => '+Q', chr(114) => '+R', chr(115) => '+S', - chr(116) => '+T', chr(117) => '+U', chr(118) => '+V', chr(119) => '+W', - chr(120) => '+X', chr(121) => '+Y', chr(122) => '+Z', chr(123) => '%P', - chr(124) => '%Q', chr(125) => '%R', chr(126) => '%S', chr(127) => '%T'); - $code_ext = ''; - $clen = strlen($code); - for ($i = 0 ; $i < $clen; ++$i) { - if (ord($code{$i}) > 127) { - return false; - } - $code_ext .= $encode[$code{$i}]; - } - return $code_ext; - } - - /** - * Calculate CODE 39 checksum (modulo 43). - * @param $code (string) code to represent. - * @return char checksum. - * @protected - */ - protected function checksum_code39($code) { - $chars = array( - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', - 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', - 'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%'); - $sum = 0; - $clen = strlen($code); - for ($i = 0 ; $i < $clen; ++$i) { - $k = array_keys($chars, $code{$i}); - $sum += $k[0]; - } - $j = ($sum % 43); - return $chars[$j]; - } - - /** - * CODE 93 - USS-93 - * Compact code similar to Code 39 - * @param $code (string) code to represent. - * @return array barcode representation. - * @protected - */ - protected function barcode_code93($code) { - $chr[48] = '131112'; // 0 - $chr[49] = '111213'; // 1 - $chr[50] = '111312'; // 2 - $chr[51] = '111411'; // 3 - $chr[52] = '121113'; // 4 - $chr[53] = '121212'; // 5 - $chr[54] = '121311'; // 6 - $chr[55] = '111114'; // 7 - $chr[56] = '131211'; // 8 - $chr[57] = '141111'; // 9 - $chr[65] = '211113'; // A - $chr[66] = '211212'; // B - $chr[67] = '211311'; // C - $chr[68] = '221112'; // D - $chr[69] = '221211'; // E - $chr[70] = '231111'; // F - $chr[71] = '112113'; // G - $chr[72] = '112212'; // H - $chr[73] = '112311'; // I - $chr[74] = '122112'; // J - $chr[75] = '132111'; // K - $chr[76] = '111123'; // L - $chr[77] = '111222'; // M - $chr[78] = '111321'; // N - $chr[79] = '121122'; // O - $chr[80] = '131121'; // P - $chr[81] = '212112'; // Q - $chr[82] = '212211'; // R - $chr[83] = '211122'; // S - $chr[84] = '211221'; // T - $chr[85] = '221121'; // U - $chr[86] = '222111'; // V - $chr[87] = '112122'; // W - $chr[88] = '112221'; // X - $chr[89] = '122121'; // Y - $chr[90] = '123111'; // Z - $chr[45] = '121131'; // - - $chr[46] = '311112'; // . - $chr[32] = '311211'; // - $chr[36] = '321111'; // $ - $chr[47] = '112131'; // / - $chr[43] = '113121'; // + - $chr[37] = '211131'; // % - $chr[128] = '121221'; // ($) - $chr[129] = '311121'; // (/) - $chr[130] = '122211'; // (+) - $chr[131] = '312111'; // (%) - $chr[42] = '111141'; // start-stop - $code = strtoupper($code); - $encode = array( - chr(0) => chr(131).'U', chr(1) => chr(128).'A', chr(2) => chr(128).'B', chr(3) => chr(128).'C', - chr(4) => chr(128).'D', chr(5) => chr(128).'E', chr(6) => chr(128).'F', chr(7) => chr(128).'G', - chr(8) => chr(128).'H', chr(9) => chr(128).'I', chr(10) => chr(128).'J', chr(11) => '£K', - chr(12) => chr(128).'L', chr(13) => chr(128).'M', chr(14) => chr(128).'N', chr(15) => chr(128).'O', - chr(16) => chr(128).'P', chr(17) => chr(128).'Q', chr(18) => chr(128).'R', chr(19) => chr(128).'S', - chr(20) => chr(128).'T', chr(21) => chr(128).'U', chr(22) => chr(128).'V', chr(23) => chr(128).'W', - chr(24) => chr(128).'X', chr(25) => chr(128).'Y', chr(26) => chr(128).'Z', chr(27) => chr(131).'A', - chr(28) => chr(131).'B', chr(29) => chr(131).'C', chr(30) => chr(131).'D', chr(31) => chr(131).'E', - chr(32) => ' ', chr(33) => chr(129).'A', chr(34) => chr(129).'B', chr(35) => chr(129).'C', - chr(36) => chr(129).'D', chr(37) => chr(129).'E', chr(38) => chr(129).'F', chr(39) => chr(129).'G', - chr(40) => chr(129).'H', chr(41) => chr(129).'I', chr(42) => chr(129).'J', chr(43) => chr(129).'K', - chr(44) => chr(129).'L', chr(45) => '-', chr(46) => '.', chr(47) => chr(129).'O', - chr(48) => '0', chr(49) => '1', chr(50) => '2', chr(51) => '3', - chr(52) => '4', chr(53) => '5', chr(54) => '6', chr(55) => '7', - chr(56) => '8', chr(57) => '9', chr(58) => chr(129).'Z', chr(59) => chr(131).'F', - chr(60) => chr(131).'G', chr(61) => chr(131).'H', chr(62) => chr(131).'I', chr(63) => chr(131).'J', - chr(64) => chr(131).'V', chr(65) => 'A', chr(66) => 'B', chr(67) => 'C', - chr(68) => 'D', chr(69) => 'E', chr(70) => 'F', chr(71) => 'G', - chr(72) => 'H', chr(73) => 'I', chr(74) => 'J', chr(75) => 'K', - chr(76) => 'L', chr(77) => 'M', chr(78) => 'N', chr(79) => 'O', - chr(80) => 'P', chr(81) => 'Q', chr(82) => 'R', chr(83) => 'S', - chr(84) => 'T', chr(85) => 'U', chr(86) => 'V', chr(87) => 'W', - chr(88) => 'X', chr(89) => 'Y', chr(90) => 'Z', chr(91) => chr(131).'K', - chr(92) => chr(131).'L', chr(93) => chr(131).'M', chr(94) => chr(131).'N', chr(95) => chr(131).'O', - chr(96) => chr(131).'W', chr(97) => chr(130).'A', chr(98) => chr(130).'B', chr(99) => chr(130).'C', - chr(100) => chr(130).'D', chr(101) => chr(130).'E', chr(102) => chr(130).'F', chr(103) => chr(130).'G', - chr(104) => chr(130).'H', chr(105) => chr(130).'I', chr(106) => chr(130).'J', chr(107) => chr(130).'K', - chr(108) => chr(130).'L', chr(109) => chr(130).'M', chr(110) => chr(130).'N', chr(111) => chr(130).'O', - chr(112) => chr(130).'P', chr(113) => chr(130).'Q', chr(114) => chr(130).'R', chr(115) => chr(130).'S', - chr(116) => chr(130).'T', chr(117) => chr(130).'U', chr(118) => chr(130).'V', chr(119) => chr(130).'W', - chr(120) => chr(130).'X', chr(121) => chr(130).'Y', chr(122) => chr(130).'Z', chr(123) => chr(131).'P', - chr(124) => chr(131).'Q', chr(125) => chr(131).'R', chr(126) => chr(131).'S', chr(127) => chr(131).'T'); - $code_ext = ''; - $clen = strlen($code); - for ($i = 0 ; $i < $clen; ++$i) { - if (ord($code{$i}) > 127) { - return false; - } - $code_ext .= $encode[$code{$i}]; - } - // checksum - $code_ext .= $this->checksum_code93($code_ext); - // add start and stop codes - $code = '*'.$code_ext.'*'; - $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); - $k = 0; - $clen = strlen($code); - for ($i = 0; $i < $clen; ++$i) { - $char = ord($code{$i}); - if(!isset($chr[$char])) { - // invalid character - return false; - } - for ($j = 0; $j < 6; ++$j) { - if (($j % 2) == 0) { - $t = true; // bar - } else { - $t = false; // space - } - $w = $chr[$char]{$j}; - $bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0); - $bararray['maxw'] += $w; - ++$k; - } - } - $bararray['bcode'][$k] = array('t' => true, 'w' => 1, 'h' => 1, 'p' => 0); - $bararray['maxw'] += 1; - ++$k; - return $bararray; - } - - /** - * Calculate CODE 93 checksum (modulo 47). - * @param $code (string) code to represent. - * @return string checksum code. - * @protected - */ - protected function checksum_code93($code) { - $chars = array( - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', - 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', - 'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%', - '<', '=', '>', '?'); - // translate special characters - $code = strtr($code, chr(128).chr(131).chr(129).chr(130), '<=>?'); - $len = strlen($code); - // calculate check digit C - $p = 1; - $check = 0; - for ($i = ($len - 1); $i >= 0; --$i) { - $k = array_keys($chars, $code{$i}); - $check += ($k[0] * $p); - ++$p; - if ($p > 20) { - $p = 1; - } - } - $check %= 47; - $c = $chars[$check]; - $code .= $c; - // calculate check digit K - $p = 1; - $check = 0; - for ($i = $len; $i >= 0; --$i) { - $k = array_keys($chars, $code{$i}); - $check += ($k[0] * $p); - ++$p; - if ($p > 15) { - $p = 1; - } - } - $check %= 47; - $k = $chars[$check]; - $checksum = $c.$k; - // resto respecial characters - $checksum = strtr($checksum, '<=>?', chr(128).chr(131).chr(129).chr(130)); - return $checksum; - } - - /** - * Checksum for standard 2 of 5 barcodes. - * @param $code (string) code to process. - * @return int checksum. - * @protected - */ - protected function checksum_s25($code) { - $len = strlen($code); - $sum = 0; - for ($i = 0; $i < $len; $i+=2) { - $sum += $code{$i}; - } - $sum *= 3; - for ($i = 1; $i < $len; $i+=2) { - $sum += ($code{$i}); - } - $r = $sum % 10; - if($r > 0) { - $r = (10 - $r); - } - return $r; - } - - /** - * MSI. - * Variation of Plessey code, with similar applications - * Contains digits (0 to 9) and encodes the data only in the width of bars. - * @param $code (string) code to represent. - * @param $checksum (boolean) if true add a checksum to the code (modulo 11) - * @return array barcode representation. - * @protected - */ - protected function barcode_msi($code, $checksum=false) { - $chr['0'] = '100100100100'; - $chr['1'] = '100100100110'; - $chr['2'] = '100100110100'; - $chr['3'] = '100100110110'; - $chr['4'] = '100110100100'; - $chr['5'] = '100110100110'; - $chr['6'] = '100110110100'; - $chr['7'] = '100110110110'; - $chr['8'] = '110100100100'; - $chr['9'] = '110100100110'; - $chr['A'] = '110100110100'; - $chr['B'] = '110100110110'; - $chr['C'] = '110110100100'; - $chr['D'] = '110110100110'; - $chr['E'] = '110110110100'; - $chr['F'] = '110110110110'; - if ($checksum) { - // add checksum - $clen = strlen($code); - $p = 2; - $check = 0; - for ($i = ($clen - 1); $i >= 0; --$i) { - $check += (hexdec($code{$i}) * $p); - ++$p; - if ($p > 7) { - $p = 2; - } - } - $check %= 11; - if ($check > 0) { - $check = 11 - $check; - } - $code .= $check; - } - $seq = '110'; // left guard - $clen = strlen($code); - for ($i = 0; $i < $clen; ++$i) { - $digit = $code{$i}; - if (!isset($chr[$digit])) { - // invalid character - return false; - } - $seq .= $chr[$digit]; - } - $seq .= '1001'; // right guard - $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); - return $this->binseq_to_array($seq, $bararray); - } - - /** - * Standard 2 of 5 barcodes. - * Used in airline ticket marking, photofinishing - * Contains digits (0 to 9) and encodes the data only in the width of bars. - * @param $code (string) code to represent. - * @param $checksum (boolean) if true add a checksum to the code - * @return array barcode representation. - * @protected - */ - protected function barcode_s25($code, $checksum=false) { - $chr['0'] = '10101110111010'; - $chr['1'] = '11101010101110'; - $chr['2'] = '10111010101110'; - $chr['3'] = '11101110101010'; - $chr['4'] = '10101110101110'; - $chr['5'] = '11101011101010'; - $chr['6'] = '10111011101010'; - $chr['7'] = '10101011101110'; - $chr['8'] = '10101110111010'; - $chr['9'] = '10111010111010'; - if ($checksum) { - // add checksum - $code .= $this->checksum_s25($code); - } - if((strlen($code) % 2) != 0) { - // add leading zero if code-length is odd - $code = '0'.$code; - } - $seq = '11011010'; - $clen = strlen($code); - for ($i = 0; $i < $clen; ++$i) { - $digit = $code{$i}; - if (!isset($chr[$digit])) { - // invalid character - return false; - } - $seq .= $chr[$digit]; - } - $seq .= '1101011'; - $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); - return $this->binseq_to_array($seq, $bararray); - } - - /** - * Convert binary barcode sequence to TCPDF barcode array. - * @param $seq (string) barcode as binary sequence. - * @param $bararray (array) barcode array. - * òparam array $bararray TCPDF barcode array to fill up - * @return array barcode representation. - * @protected - */ - protected function binseq_to_array($seq, $bararray) { - $len = strlen($seq); - $w = 0; - $k = 0; - for ($i = 0; $i < $len; ++$i) { - $w += 1; - if (($i == ($len - 1)) OR (($i < ($len - 1)) AND ($seq{$i} != $seq{($i+1)}))) { - if ($seq{$i} == '1') { - $t = true; // bar - } else { - $t = false; // space - } - $bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0); - $bararray['maxw'] += $w; - ++$k; - $w = 0; - } - } - return $bararray; - } - - /** - * Interleaved 2 of 5 barcodes. - * Compact numeric code, widely used in industry, air cargo - * Contains digits (0 to 9) and encodes the data in the width of both bars and spaces. - * @param $code (string) code to represent. - * @param $checksum (boolean) if true add a checksum to the code - * @return array barcode representation. - * @protected - */ - protected function barcode_i25($code, $checksum=false) { - $chr['0'] = '11221'; - $chr['1'] = '21112'; - $chr['2'] = '12112'; - $chr['3'] = '22111'; - $chr['4'] = '11212'; - $chr['5'] = '21211'; - $chr['6'] = '12211'; - $chr['7'] = '11122'; - $chr['8'] = '21121'; - $chr['9'] = '12121'; - $chr['A'] = '11'; - $chr['Z'] = '21'; - if ($checksum) { - // add checksum - $code .= $this->checksum_s25($code); - } - if((strlen($code) % 2) != 0) { - // add leading zero if code-length is odd - $code = '0'.$code; - } - // add start and stop codes - $code = 'AA'.strtolower($code).'ZA'; - - $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); - $k = 0; - $clen = strlen($code); - for ($i = 0; $i < $clen; $i = ($i + 2)) { - $char_bar = $code{$i}; - $char_space = $code{$i+1}; - if((!isset($chr[$char_bar])) OR (!isset($chr[$char_space]))) { - // invalid character - return false; - } - // create a bar-space sequence - $seq = ''; - $chrlen = strlen($chr[$char_bar]); - for ($s = 0; $s < $chrlen; $s++){ - $seq .= $chr[$char_bar]{$s} . $chr[$char_space]{$s}; - } - $seqlen = strlen($seq); - for ($j = 0; $j < $seqlen; ++$j) { - if (($j % 2) == 0) { - $t = true; // bar - } else { - $t = false; // space - } - $w = $seq{$j}; - $bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0); - $bararray['maxw'] += $w; - ++$k; - } - } - return $bararray; - } - - /** - * C128 barcodes. - * Very capable code, excellent density, high reliability; in very wide use world-wide - * @param $code (string) code to represent. - * @param $type (string) barcode type: A, B, C or empty for automatic switch (AUTO mode) - * @return array barcode representation. - * @protected - */ - protected function barcode_c128($code, $type='') { - $chr = array( - '212222', /* 00 */ - '222122', /* 01 */ - '222221', /* 02 */ - '121223', /* 03 */ - '121322', /* 04 */ - '131222', /* 05 */ - '122213', /* 06 */ - '122312', /* 07 */ - '132212', /* 08 */ - '221213', /* 09 */ - '221312', /* 10 */ - '231212', /* 11 */ - '112232', /* 12 */ - '122132', /* 13 */ - '122231', /* 14 */ - '113222', /* 15 */ - ... [truncated message content] |