32
1
mirror of https://github.com/vdm-io/tcpdf.git synced 2024-11-22 12:55:10 +00:00
This commit is contained in:
nicolaasuni 2009-04-09 19:29:09 +02:00
parent 4c6ed496d9
commit 28ab8bdee1
16 changed files with 927 additions and 368 deletions

View File

@ -1,3 +1,9 @@
4.5.037 (2009-04-09)
- General performances were improved.
- The signature of the method utf8Bidi() was changed.
- The method UniArrSubString() was added.
- Experimental support for 2D barcodes were added (see example n. 50 and 2dbarcodes.php class).
4.5.036 (2009-04-03)
- TCPDF methods can be called inside the HTML code (see example n. 49).
- All tag attributes, such as <p align="center"> must be enclosed within double quotes.

View File

@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
------------------------------------------------------------
Name: TCPDF
Version: 4.5.036
Release date: 2009-04-03
Version: 4.5.037
Release date: 2009-04-09
Author: Nicola Asuni
Copyright (c) 2001-2009:

View File

@ -45,7 +45,7 @@
<div class="credit">
<hr />
Documentation generated on Fri, 03 Apr 2009 12:04:30 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Thu, 09 Apr 2009 19:28:56 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

File diff suppressed because it is too large Load Diff

View File

@ -640,7 +640,7 @@ $type)</code>
<div class="credit">
<hr />
Documentation generated on Fri, 03 Apr 2009 12:04:30 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Thu, 09 Apr 2009 19:28:56 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -96,7 +96,7 @@ PHP class to creates array representations for common 1D barcodes to be used wit
<div class="credit">
<hr />
Documentation generated on Fri, 03 Apr 2009 12:04:30 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Thu, 09 Apr 2009 19:28:56 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -507,7 +507,7 @@ Configuration file for TCPDF.<br /><br /><br /><br />
<div class="credit">
<hr />
Documentation generated on Fri, 03 Apr 2009 12:04:35 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Thu, 09 Apr 2009 19:29:01 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -88,7 +88,7 @@ Array of WEB safe colors.<br /><br /><br /><br />
<div class="credit">
<hr />
Documentation generated on Fri, 03 Apr 2009 12:04:30 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Thu, 09 Apr 2009 19:28:56 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -73,7 +73,7 @@ This is a PHP class for generating PDF documents without requiring external exte
<td><b>author:</b>&nbsp;&nbsp;</td><td>Nicola Asuni</td>
</tr>
<tr>
<td><b>version:</b>&nbsp;&nbsp;</td><td>4.5.036</td>
<td><b>version:</b>&nbsp;&nbsp;</td><td>4.5.037</td>
</tr>
<tr>
<td><b>copyright:</b>&nbsp;&nbsp;</td><td>2002-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>
@ -104,7 +104,7 @@ unicode data<br /><br /></div>
<div class="tags">
<table width="90%" border="0" cellspacing="0" cellpadding="1"><tr><td class="code_border">
<table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="code">
<code>PDF_PRODUCER = 'TCPDF 4.5.036 (http://www.tcpdf.org)'</code>
<code>PDF_PRODUCER = 'TCPDF 4.5.037 (http://www.tcpdf.org)'</code>
</td></tr></table>
</td></tr></table>
@ -115,7 +115,7 @@ unicode data<br /><br /></div>
<div class="credit">
<hr />
Documentation generated on Fri, 03 Apr 2009 12:04:30 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Thu, 09 Apr 2009 19:28:57 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -237,7 +237,7 @@ Unicode Include file for TCPDF.<br /><br /><br /><br />
<div class="credit">
<hr />
Documentation generated on Fri, 03 Apr 2009 12:04:35 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Thu, 09 Apr 2009 19:29:01 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -147,6 +147,12 @@
<dl>
<dt><b>$cache_file_lenght</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$cache_file_lenght">TCPDF::$cache_file_lenght</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Array used to store the lenghts of cache files</dd>
<dt><b>$cache_maxsize_UTF8StringToArray</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$cache_maxsize_UTF8StringToArray">TCPDF::$cache_maxsize_UTF8StringToArray</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Maximum size of cache array used for UTF8StringToArray() method.</dd>
<dt><b>$cache_size_UTF8StringToArray</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$cache_size_UTF8StringToArray">TCPDF::$cache_size_UTF8StringToArray</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Current size of cache array used for UTF8StringToArray() method.</dd>
<dt><b>$cache_UTF8StringToArray</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$cache_UTF8StringToArray">TCPDF::$cache_UTF8StringToArray</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Cache array for UTF8StringToArray() method.</dd>
<dt><b>$cell_height_ratio</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$cell_height_ratio">TCPDF::$cell_height_ratio</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Default cell height ratio.</dd>
<dt><b>$cMargin</b></dt>
@ -1089,10 +1095,14 @@
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$Uvalue">TCPDF::$Uvalue</a><br>&nbsp;&nbsp;&nbsp;&nbsp;U entry in pdf document</dd>
<dt><b>unhtmlentities</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodunhtmlentities">TCPDF::unhtmlentities()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Reverse function for htmlentities.</dd>
<dt><b>UniArrSubString</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodUniArrSubString">TCPDF::UniArrSubString()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Extract a slice of the $uniarr array and return it as string.</dd>
<dt><b>unichr</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodunichr">TCPDF::unichr()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns the unicode caracter specified by UTF-8 code</dd>
<dt><b>unicode_data.php</b></dt>
<dd>procedural page <a href="com-tecnick-tcpdf/_unicode_data.php.html">unicode_data.php</a></dd>
<dt><b>UTF8ArrayToUniArray</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodUTF8ArrayToUniArray">TCPDF::UTF8ArrayToUniArray()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Convert an array of UTF8 values to array of unicode characters</dd>
<dt><b>UTF8ArrSubString</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodUTF8ArrSubString">TCPDF::UTF8ArrSubString()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Extract a slice of the $strarr array and return it as string.</dd>
<dt><b>utf8Bidi</b></dt>
@ -1132,7 +1142,9 @@
<dt><b>Write</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodWrite">TCPDF::Write()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;This method prints text from the current position.<br /></dd>
<dt><b>write1DBarcode</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodwrite1DBarcode">TCPDF::write1DBarcode()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Print Barcode.</dd>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodwrite1DBarcode">TCPDF::write1DBarcode()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Print 1D Barcode.</dd>
<dt><b>write2DBarcode</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodwrite2DBarcode">TCPDF::write2DBarcode()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Print 2D Barcode.</dd>
<dt><b>writeBarcode</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodwriteBarcode">TCPDF::writeBarcode()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;This function is DEPRECATED, please use the new write1DBarcode() function.</dd>
<dt><b>writeDiskCache</b></dt>
@ -1302,7 +1314,7 @@
<a href="elementindex.html#top">top</a><br>
<div class="credit">
<hr />
Documentation generated on Fri, 03 Apr 2009 12:04:30 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Thu, 09 Apr 2009 19:28:56 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -296,6 +296,12 @@
<dl>
<dt><b>$cache_file_lenght</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$cache_file_lenght">TCPDF::$cache_file_lenght</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Array used to store the lenghts of cache files</dd>
<dt><b>$cache_maxsize_UTF8StringToArray</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$cache_maxsize_UTF8StringToArray">TCPDF::$cache_maxsize_UTF8StringToArray</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Maximum size of cache array used for UTF8StringToArray() method.</dd>
<dt><b>$cache_size_UTF8StringToArray</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$cache_size_UTF8StringToArray">TCPDF::$cache_size_UTF8StringToArray</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Current size of cache array used for UTF8StringToArray() method.</dd>
<dt><b>$cache_UTF8StringToArray</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$cache_UTF8StringToArray">TCPDF::$cache_UTF8StringToArray</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Cache array for UTF8StringToArray() method.</dd>
<dt><b>$cell_height_ratio</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$cell_height_ratio">TCPDF::$cell_height_ratio</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Default cell height ratio.</dd>
<dt><b>$cMargin</b></dt>
@ -1238,10 +1244,14 @@
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$Uvalue">TCPDF::$Uvalue</a><br>&nbsp;&nbsp;&nbsp;&nbsp;U entry in pdf document</dd>
<dt><b>unhtmlentities</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodunhtmlentities">TCPDF::unhtmlentities()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Reverse function for htmlentities.</dd>
<dt><b>UniArrSubString</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodUniArrSubString">TCPDF::UniArrSubString()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Extract a slice of the $uniarr array and return it as string.</dd>
<dt><b>unichr</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodunichr">TCPDF::unichr()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns the unicode caracter specified by UTF-8 code</dd>
<dt><b>unicode_data.php</b></dt>
<dd>procedural page <a href="com-tecnick-tcpdf/_unicode_data.php.html">unicode_data.php</a></dd>
<dt><b>UTF8ArrayToUniArray</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodUTF8ArrayToUniArray">TCPDF::UTF8ArrayToUniArray()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Convert an array of UTF8 values to array of unicode characters</dd>
<dt><b>UTF8ArrSubString</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodUTF8ArrSubString">TCPDF::UTF8ArrSubString()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Extract a slice of the $strarr array and return it as string.</dd>
<dt><b>utf8Bidi</b></dt>
@ -1281,7 +1291,9 @@
<dt><b>Write</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodWrite">TCPDF::Write()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;This method prints text from the current position.<br /></dd>
<dt><b>write1DBarcode</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodwrite1DBarcode">TCPDF::write1DBarcode()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Print Barcode.</dd>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodwrite1DBarcode">TCPDF::write1DBarcode()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Print 1D Barcode.</dd>
<dt><b>write2DBarcode</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodwrite2DBarcode">TCPDF::write2DBarcode()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Print 2D Barcode.</dd>
<dt><b>writeBarcode</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodwriteBarcode">TCPDF::writeBarcode()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;This function is DEPRECATED, please use the new write1DBarcode() function.</dd>
<dt><b>writeDiskCache</b></dt>
@ -1325,7 +1337,7 @@
<a href="elementindex_com-tecnick-tcpdf.html#top">top</a><br>
<div class="credit">
<hr />
Documentation generated on Fri, 03 Apr 2009 12:04:30 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Thu, 09 Apr 2009 19:28:56 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</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 Fri, 03 Apr 2009 12:04:35 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Thu, 09 Apr 2009 19:29:02 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -58,7 +58,7 @@
This documentation was generated by <a href="http://www.phpdoc.org">phpDocumentor v1.4.1</a><br />
<div class="credit">
<hr />
Documentation generated on Fri, 03 Apr 2009 12:04:30 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Thu, 09 Apr 2009 19:28:56 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -58,7 +58,7 @@
This documentation was generated by <a href="http://www.phpdoc.org">phpDocumentor v1.4.1</a><br />
<div class="credit">
<hr />
Documentation generated on Fri, 03 Apr 2009 12:04:30 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Thu, 09 Apr 2009 19:28:56 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

354
tcpdf.php
View File

@ -2,9 +2,9 @@
//============================================================+
// File name : tcpdf.php
// Begin : 2002-08-03
// Last Update : 2009-04-03
// Last Update : 2009-04-07
// Author : Nicola Asuni - info@tecnick.com - http://www.tcpdf.org
// Version : 4.5.036
// Version : 4.5.037
// License : GNU LGPL (http://www.gnu.org/copyleft/lesser.html)
// ----------------------------------------------------------------------------
// Copyright (C) 2002-2009 Nicola Asuni - Tecnick.com S.r.l.
@ -122,7 +122,7 @@
* @copyright 2002-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 4.5.036
* @version 4.5.037
*/
/**
@ -146,14 +146,14 @@ if (!class_exists('TCPDF', false)) {
/**
* define default PDF document producer
*/
define('PDF_PRODUCER', 'TCPDF 4.5.036 (http://www.tcpdf.org)');
define('PDF_PRODUCER', 'TCPDF 4.5.037 (http://www.tcpdf.org)');
/**
* This is a PHP class for generating PDF documents without requiring external extensions.<br>
* TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br>
* @name TCPDF
* @package com.tecnick.tcpdf
* @version 4.5.036
* @version 4.5.037
* @author Nicola Asuni - info@tecnick.com
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
@ -1239,7 +1239,30 @@ if (!class_exists('TCPDF', false)) {
* @access protected
* @since 4.5.030 (2009-03-20)
*/
protected $theadMargin = '';
protected $theadMargin = '';
/**
* Cache array for UTF8StringToArray() method.
* @access protected
* @since 4.5.037 (2009-04-07)
*/
protected $cache_UTF8StringToArray = array();
/**
* Maximum size of cache array used for UTF8StringToArray() method.
* @access protected
* @since 4.5.037 (2009-04-07)
*/
protected $cache_maxsize_UTF8StringToArray = 8;
/**
* Current size of cache array used for UTF8StringToArray() method.
* @access protected
* @since 4.5.037 (2009-04-07)
*/
protected $cache_size_UTF8StringToArray = 0;
//------------------------------------------------------------
// METHODS
//------------------------------------------------------------
@ -1355,7 +1378,7 @@ if (!class_exists('TCPDF', false)) {
// set default JPEG quality
$this->jpeg_quality = 75;
// initialize some settings
$this->utf8Bidi(array(''));
$this->utf8Bidi(array(''), '');
// set default font
$this->SetFont($this->FontFamily, $this->FontStyle, $this->FontSizePt);
}
@ -2722,7 +2745,7 @@ if (!class_exists('TCPDF', false)) {
* @since 1.2
*/
public function GetStringWidth($s, $fontname='', $fontstyle='', $fontsize=0) {
return $this->GetArrStringWidth($this->utf8Bidi($this->UTF8StringToArray($s), $this->tmprtl), $fontname, $fontstyle, $fontsize);
return $this->GetArrStringWidth($this->utf8Bidi($this->UTF8StringToArray($s), $s, $this->tmprtl), $fontname, $fontstyle, $fontsize);
}
/**
@ -3190,7 +3213,7 @@ if (!class_exists('TCPDF', false)) {
//Output a string
if ($this->rtl) {
// bidirectional algorithm (some chars may be changed affecting the line length)
$s = $this->utf8Bidi($this->UTF8StringToArray($txt), $this->tmprtl);
$s = $this->utf8Bidi($this->UTF8StringToArray($txt), $txt, $this->tmprtl);
$l = $this->GetArrStringWidth($s);
$xr = $this->w - $x - $this->GetArrStringWidth($s);
} else {
@ -3850,10 +3873,18 @@ if (!class_exists('TCPDF', false)) {
} else {
$arabic = false;
}
// check if string contains RTL text
if ($arabic OR $this->tmprtl OR preg_match(K_RE_PATTERN_RTL, $txt)) {
$rtlmode = true;
} else {
$rtlmode = false;
}
// get a char width
$chrwidth = $this->GetCharWidth('.');
// get array of chars
$chars = $this->UTF8StringToArray($s);
// get array of unicode values
$chars = $this->UTF8StringToArray($s);
// get array of chars
$uchars = $this->UTF8ArrayToUniArray($chars);
// get the number of characters
$nb = count($chars);
// handle single space character
@ -3907,10 +3938,16 @@ if (!class_exists('TCPDF', false)) {
}
} else {
$talign = $align;
}
}
$tmpstr = $this->UniArrSubString($uchars, $j, $i);
if ($firstline) {
$startx = $this->x;
$linew = $this->GetArrStringWidth($this->utf8Bidi(array_slice($chars, $j, $i), $this->tmprtl));
$startx = $this->x;
$tmparr = array_slice($chars, $j, $i);
if ($rtlmode) {
$tmparr = $this->utf8Bidi($tmparr, $tmpstr, $this->tmprtl);
}
$linew = $this->GetArrStringWidth($tmparr);
unset($tmparr);
if ($this->rtl) {
$this->endlinex = $startx - $linew;
} else {
@ -3922,10 +3959,11 @@ if (!class_exists('TCPDF', false)) {
$this->cMargin = 0;
}
}
$this->Cell($w, $h, $this->UTF8ArrSubString($chars, $j, $i), 0, 1, $talign, $fill, $link, $stretch);
$this->Cell($w, $h, $tmpstr, 0, 1, $talign, $fill, $link, $stretch);
unset($tmpstr);
if ($firstline) {
$this->cMargin = $tmpcmargin;
return ($this->UTF8ArrSubString($chars, $i));
return ($this->UniArrSubString($uchars, $i));
}
++$nl;
$j = $i + 1;
@ -3955,7 +3993,7 @@ if (!class_exists('TCPDF', false)) {
if ((($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) AND ($arabic)) {
// with bidirectional algorithm some chars may be changed affecting the line length
// *** very slow ***
$l = $this->GetArrStringWidth($this->utf8Bidi(array_slice($chars, $j, $i-$j+1), $this->tmprtl));
$l = $this->GetArrStringWidth($this->utf8Bidi(array_slice($chars, $j, $i-$j+1), '', $this->tmprtl));
} else {
$l += $this->GetCharWidth($c);
}
@ -3969,13 +4007,19 @@ if (!class_exists('TCPDF', false)) {
$this->Cell($w, $h, '', 0, 1);
$linebreak = true;
if ($firstline) {
return ($this->UTF8ArrSubString($chars, $j));
return ($this->UniArrSubString($uchars, $j));
}
} else {
// truncate the word because do not fit on column
// truncate the word because do not fit on column
$tmpstr = $this->UniArrSubString($uchars, $j, $i);
if ($firstline) {
$startx = $this->x;
$linew = $this->GetArrStringWidth($this->utf8Bidi(array_slice($chars, $j, $i), $this->tmprtl));
$startx = $this->x;
$tmparr = array_slice($chars, $j, $i);
if ($rtlmode) {
$tmparr = $this->utf8Bidi($tmparr, $tmpstr, $this->tmprtl);
}
$linew = $this->GetArrStringWidth($tmparr);
unset($tmparr);
if ($this->rtl) {
$this->endlinex = $startx - $linew;
} else {
@ -3987,10 +4031,11 @@ if (!class_exists('TCPDF', false)) {
$this->cMargin = 0;
}
}
$this->Cell($w, $h, $this->UTF8ArrSubString($chars, $j, $i), 0, 1, $align, $fill, $link, $stretch);
$this->Cell($w, $h, $tmpstr, 0, 1, $align, $fill, $link, $stretch);
unset($tmpstr);
if ($firstline) {
$this->cMargin = $tmpcmargin;
return ($this->UTF8ArrSubString($chars, $i));
return ($this->UniArrSubString($uchars, $i));
}
$j = $i;
--$i;
@ -4016,10 +4061,16 @@ if (!class_exists('TCPDF', false)) {
$shy_width = 0;
$shy_char_left = '';
$shy_char_right = '';
}
}
$tmpstr = $this->UniArrSubString($uchars, $j, ($sep + $endspace));
if ($firstline) {
$startx = $this->x;
$linew = $this->GetArrStringWidth($this->utf8Bidi(array_slice($chars, $j, ($sep + $endspace)), $this->tmprtl));
$startx = $this->x;
$tmparr = array_slice($chars, $j, ($sep + $endspace));
if ($rtlmode) {
$tmparr = $this->utf8Bidi($tmparr, $tmpstr, $this->tmprtl);
}
$linew = $this->GetArrStringWidth($tmparr);
unset($tmparr);
if ($this->rtl) {
$this->endlinex = $startx - $linew - $shy_width;
} else {
@ -4032,11 +4083,12 @@ if (!class_exists('TCPDF', false)) {
}
}
// print the line
$this->Cell($w, $h, $shy_char_left.$this->UTF8ArrSubString($chars, $j, ($sep + $endspace)).$shy_char_right, 0, 1, $align, $fill, $link, $stretch);
$this->Cell($w, $h, $shy_char_left.$tmpstr.$shy_char_right, 0, 1, $align, $fill, $link, $stretch);
unset($tmpstr);
if ($firstline) {
// return the remaining text
$this->cMargin = $tmpcmargin;
return ($this->UTF8ArrSubString($chars, ($sep + $endspace)));
return ($this->UniArrSubString($uchars, ($sep + $endspace)));
}
$i = $sep;
$sep = -1;
@ -4088,10 +4140,16 @@ if (!class_exists('TCPDF', false)) {
$w = $l;
break;
}
}
}
$tmpstr = $this->UniArrSubString($uchars, $j, $nb);
if ($firstline) {
$startx = $this->x;
$linew = $this->GetArrStringWidth($this->utf8Bidi(array_slice($chars, $j, $nb), $this->tmprtl));
$startx = $this->x;
$tmparr = array_slice($chars, $j, $nb);
if ($rtlmode) {
$tmparr = $this->utf8Bidi($tmparr, $tmpstr, $this->tmprtl);
}
$linew = $this->GetArrStringWidth($tmparr);
unset($tmparr);
if ($this->rtl) {
$this->endlinex = $startx - $linew;
} else {
@ -4103,10 +4161,11 @@ if (!class_exists('TCPDF', false)) {
$this->cMargin = 0;
}
}
$this->Cell($w, $h, $this->UTF8ArrSubString($chars, $j, $nb), 0, $ln, $align, $fill, $link, $stretch);
$this->Cell($w, $h, $tmpstr, 0, $ln, $align, $fill, $link, $stretch);
unset($tmpstr);
if ($firstline) {
$this->cMargin = $tmpcmargin;
return ($this->UTF8ArrSubString($chars, $nb));
return ($this->UniArrSubString($uchars, $nb));
}
++$nl;
}
@ -4129,7 +4188,7 @@ if (!class_exists('TCPDF', false)) {
}
}
/**
/**
* Extract a slice of the $strarr array and return it as string.
* @param string $strarr The input array of characters.
* @param int $start the starting element of $strarr.
@ -4150,6 +4209,40 @@ if (!class_exists('TCPDF', false)) {
}
return $string;
}
/**
* Extract a slice of the $uniarr array and return it as string.
* @param string $uniarr The input array of characters.
* @param int $start the starting element of $strarr.
* @param int $end first element that will not be returned.
* @return Return part of a string
* @access public
* @since 4.5.037 (2009-04-07)
*/
public function UniArrSubString($uniarr, $start='', $end='') {
if (strlen($start) == 0) {
$start = 0;
}
if (strlen($end) == 0) {
$end = count($uniarr);
}
$string = '';
for ($i=$start; $i < $end; ++$i) {
$string .= $uniarr[$i];
}
return $string;
}
/**
* Convert an array of UTF8 values to array of unicode characters
* @param string $ta The input array of UTF8 values.
* @return Return array of unicode characters
* @access public
* @since 4.5.037 (2009-04-07)
*/
public function UTF8ArrayToUniArray($ta) {
return array_map(array($this, 'unichr'), $ta);
}
/**
* Returns the unicode caracter specified by UTF-8 code
@ -6388,13 +6481,25 @@ if (!class_exists('TCPDF', false)) {
* @since 1.53.0.TC005 (2005-01-05)
*/
protected function UTF8StringToArray($str) {
if (isset($this->cache_UTF8StringToArray[$str])) {
// return cached value
return($this->cache_UTF8StringToArray[$str]);
}
// check cache size
if ($this->cache_size_UTF8StringToArray >= $this->cache_maxsize_UTF8StringToArray) {
// remove first element
array_shift($this->cache_UTF8StringToArray);
}
++$this->cache_size_UTF8StringToArray;
if (!$this->isunicode) {
// split string into array of equivalent codes
$strarr = array();
$strlen = strlen($str);
for($i=0; $i < $strlen; ++$i) {
$strarr[] = ord($str{$i});
}
}
// insert new value on cache
$this->cache_UTF8StringToArray[$str] = $strarr;
return $strarr;
}
$unicode = array(); // array containing unicode values
@ -6450,7 +6555,9 @@ if (!class_exists('TCPDF', false)) {
$bytes = array();
$numbytes = 1;
}
}
}
// insert new value on cache
$this->cache_UTF8StringToArray[$str] = $unicode;
return $unicode;
}
@ -8067,26 +8174,29 @@ if (!class_exists('TCPDF', false)) {
* @since 2.1.000 (2008-01-08)
*/
protected function utf8StrRev($str, $setbom=false, $forcertl=false) {
return $this->arrUTF8ToUTF16BE($this->utf8Bidi($this->UTF8StringToArray($str), $forcertl), $setbom);
return $this->arrUTF8ToUTF16BE($this->utf8Bidi($this->UTF8StringToArray($str), $str, $forcertl), $setbom);
}
/**
* Reverse the RLT substrings using the Bidirectional Algorithm (http://unicode.org/reports/tr9/).
* @param array $ta array of characters composing the string.
* @param array $ta array of characters composing the string.
* @param string $str string to process
* @param bool $forcertl if 'R' forces RTL, if 'L' forces LTR
* @return string
* @author Nicola Asuni
* @access protected
* @since 2.4.000 (2008-03-06)
*/
protected function utf8Bidi($ta, $forcertl=false) {
protected function utf8Bidi($ta, $str='', $forcertl=false) {
global $unicode, $unicode_mirror, $unicode_arlet, $laa_array, $diacritics;
// paragraph embedding level
$pel = 0;
// max level
$maxlevel = 0;
// create string from array
$str = $this->UTF8ArrSubString($ta);
$maxlevel = 0;
if (empty($str)) {
// create string from array
$str = $this->UTF8ArrSubString($ta);
}
// check if string contains arabic text
if (preg_match(K_RE_PATTERN_ARABIC, $str)) {
$arabic = true;
@ -9969,16 +10079,16 @@ if (!class_exists('TCPDF', false)) {
}
/**
* Print Barcode.
* Print 1D Barcode.
* @param string $code code to print
* @param string $type type of barcode.
* @param int $x x position in user units
* @param int $y y position in user units
* @param int $w width in user units
* @param int $h height position in user units
* @param int $h height in user units
* @param float $xres width of the smallest bar in user units
* @param array $style array of options:<ul><li>string $style['position'] barcode position inside the specified width: L = left (default for LTR); C = center; R = right (default for RTL); S = stretch</li><li>boolean $style['border'] if true prints a border around the barcode</li><li>int $style['padding'] padding to leave around the barcode in user units</li><li>array $style['fgcolor'] color array for bars and text</li><li>mixed $style['bgcolor'] color array for background or false for transparent</li><li>boolean $style["text"] boolean if true prints text below the barcode</li><li>string $style['font'] font name for text</li><li>int $style['fontsize'] font size for text</li><li>int $style['stretchtext']: 0 = disabled; 1 = horizontal scaling only if necessary; 2 = forced horizontal scaling; 3 = character spacing only if necessary; 4 = forced character spacing</li></ul>
* @param string $align Indicates the alignment of the pointer next to image insertion relative to image height. The value can be:<ul><li>T: top-right for LTR or top-left for RTL</li><li>M: middle-right for LTR or middle-left for RTL</li><li>B: bottom-right for LTR or bottom-left for RTL</li><li>N: next line</li></ul>
* @param string $align Indicates the alignment of the pointer next to barcode insertion relative to barcode height. The value can be:<ul><li>T: top-right for LTR or top-left for RTL</li><li>M: middle-right for LTR or middle-left for RTL</li><li>B: bottom-right for LTR or bottom-left for RTL</li><li>N: next line</li></ul>
* @author Nicola Asuni
* @since 3.1.000 (2008-06-09)
* @access public
@ -9991,10 +10101,10 @@ if (!class_exists('TCPDF', false)) {
// save current graphic settings
$gvars = $this->getGraphicVars();
// create new barcode object
$barcodeobj = new TCPDFbarcode($code, $type);
$barcodeobj = new TCPDFBarcode($code, $type);
$arrcode = $barcodeobj->getBarcodeArray();
if ($arrcode === false) {
$this->Error('Error in barcode string');
$this->Error('Error in 1D barcode string');
}
// set default values
if (!isset($style['position'])) {
@ -10117,9 +10227,9 @@ if (!class_exists('TCPDF', false)) {
foreach ($arrcode['bcode'] as $k => $v) {
$bw = ($v['w'] * $xres);
if ($v['t']) {
// braw a vertical bar
// draw a vertical bar
$ypos = $y + $style['padding'] + ($v['p'] * $barh / $arrcode['maxh']);
$this->Rect($xpos, $ypos, $bw, ($v['h'] * $barh / $arrcode['maxh']), 'DF', array('L'=>0, 'T'=>0, 'R'=>0, 'B'=>0), $style['fgcolor']);
$this->Rect($xpos, $ypos, $bw, ($v['h'] * $barh / $arrcode['maxh']), 'DF', array(), $style['fgcolor']);
}
$xpos += $bw;
}
@ -10220,6 +10330,152 @@ if (!class_exists('TCPDF', false)) {
$newstyle['stretchtext'] = 4;
}
$this->write1DBarcode($code, $type, $x, $y, $w, $h, $xres, $newstyle, '');
}
/**
* Print 2D Barcode.
* @param string $code code to print
* @param string $type type of barcode.
* @param int $x x position in user units
* @param int $y y position in user units
* @param int $w width in user units
* @param int $h height in user units
* @param array $style array of options:<ul><li>boolean $style['border'] if true prints a border around the barcode</li><li>int $style['padding'] padding to leave around the barcode in user units</li><li>array $style['fgcolor'] color array for bars and text</li><li>mixed $style['bgcolor'] color array for background or false for transparent</li></ul>
* @param string $align Indicates the alignment of the pointer next to barcode insertion relative to barcode height. The value can be:<ul><li>T: top-right for LTR or top-left for RTL</li><li>M: middle-right for LTR or middle-left for RTL</li><li>B: bottom-right for LTR or bottom-left for RTL</li><li>N: next line</li></ul>
* @author Nicola Asuni
* @since 4.5.037 (2009-04-07)
* @access public
*/
public function write2DBarcode($code, $type, $x='', $y='', $w='', $h='', $style='', $align='') {
if (empty($code)) {
return;
}
require_once(dirname(__FILE__).'/2dbarcodes.php');
// save current graphic settings
$gvars = $this->getGraphicVars();
// create new barcode object
$barcodeobj = new TCPDF2DBarcode($code, $type);
$arrcode = $barcodeobj->getBarcodeArray();
if ($arrcode === false) {
$this->Error('Error in 2D barcode string');
}
// set default values
if (!isset($style['padding'])) {
$style['padding'] = 0;
}
if (!isset($style['fgcolor'])) {
$style['fgcolor'] = array(0,0,0); // default black
}
if (!isset($style['bgcolor'])) {
$style['bgcolor'] = false; // default transparent
}
if (!isset($style['border'])) {
$style['border'] = false;
}
// set foreground color
$this->SetDrawColorArray($style['fgcolor']);
if (empty($x)) {
$x = $this->GetX();
}
if ($this->rtl) {
$x = $this->w - $x;
}
if (empty($y)) {
$y = $this->GetY();
}
if (empty($w) OR ($w <= 0)) {
if ($this->rtl) {
$w = $x - $this->lMargin;
} else {
$w = $this->w - $this->rMargin - $x;
}
}
if (empty($h) OR ($h <= 0)) {
// 2d barcodes are square by default
$h = $w;
}
if ($this->checkPageBreak($h)) {
$y = $this->y;
}
// calculate barcode size (excluding padding)
$bw = $w - (2 * $style['padding']);
$bh = $h - (2 * $style['padding']);
// calculate starting coordinates
if ($this->rtl) {
$xpos = $x - $w;
} else {
$xpos = $x;
}
$xpos += $style['padding'];
$ypos = $y + $style['padding'];
// barcode is always printed in LTR direction
$tempRTL = $this->rtl;
$this->rtl = false;
// print background color
if ($style['bgcolor']) {
$this->Rect($x, $y, $w, $h, 'DF', '', $style['bgcolor']);
} elseif ($style['border']) {
$this->Rect($x, $y, $w, $h, 'D');
}
// print barcode cells
if ($arrcode !== false) {
$rows = $arrcode['num_rows'];
$cols = $arrcode['num_cols'];
// calculate dimension of single barcode cell
$cw = $bw / $cols;
$ch = $bh / $rows;
// for each row
for ($r = 0; $r < $rows; ++$r) {
$xr = $xpos;
// for each column
for ($c = 0; $c < $cols; ++$c) {
if ($arrcode['bcode'][$r][$c] == 1) {
// draw a single barcode cell
$this->Rect($xr, $ypos, $cw, $ch, 'DF', array(), $style['fgcolor']);
}
$xr += $cw;
}
$ypos += $ch;
}
}
// restore original direction
$this->rtl = $tempRTL;
// restore previous settings
$this->setGraphicVars($gvars);
// set bottomcoordinates
$this->img_rb_y = $y + $h;
if ($this->rtl) {
// set left side coordinate
$this->img_rb_x = ($this->w - $x - $w);
} else {
// set right side coordinate
$this->img_rb_x = $x + $w;
}
// set pointer to align the successive text/objects
switch($align) {
case 'T':{
$this->y = $y;
$this->x = $this->img_rb_x;
break;
}
case 'M':{
$this->y = $y + round($h/2);
$this->x = $this->img_rb_x;
break;
}
case 'B':{
$this->y = $this->img_rb_y;
$this->x = $this->img_rb_x;
break;
}
case 'N':{
$this->SetY($this->img_rb_y);
break;
}
default:{
break;
}
}
}
/**