32
1
mirror of https://github.com/vdm-io/tcpdf.git synced 2024-11-26 06:17:33 +00:00
This commit is contained in:
nicolaasuni 2010-08-14 20:53:02 +02:00
parent 3b27903a25
commit c26ad199ce
23 changed files with 646 additions and 604 deletions

View File

@ -1,3 +1,8 @@
5.8.002 (2010-08-14)
- HTML alignments were improved
- IMPORTANT: Default regular expression to find spaces has been changed to exclude the non-breaking-space (160 DEC- A0 HEX). If you are using setSpacesRE() method, please read the new documentation.
- Example n. 1 was updated.
5.8.001 (2010-08-12) 5.8.001 (2010-08-12)
- Bug #3043650 "subsetchars incorrectly cached" was fixed. - Bug #3043650 "subsetchars incorrectly cached" was fixed.

View File

@ -8,8 +8,8 @@ http: sourceforge.net/donate/index.php?group_id=128076
------------------------------------------------------------ ------------------------------------------------------------
Name: TCPDF Name: TCPDF
Version: 5.8.001 Version: 5.8.002
Release date: 2010-08-12 Release date: 2010-08-14
Author: Nicola Asuni Author: Nicola Asuni
Copyright (c) 2002-2010: Copyright (c) 2002-2010:

View File

@ -60,7 +60,7 @@
<div class="credit"> <div class="credit">
<hr /> <hr />
Documentation generated on Thu, 12 Aug 2010 15:16:02 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> Documentation generated on Sat, 14 Aug 2010 20:52:49 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div> </div>
</td></tr></table> </td></tr></table>
</td> </td>

View File

@ -1003,7 +1003,7 @@ $code)</code>
<div class="credit"> <div class="credit">
<hr /> <hr />
Documentation generated on Thu, 12 Aug 2010 15:16:03 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> Documentation generated on Sat, 14 Aug 2010 20:52:50 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div> </div>
</td></tr></table> </td></tr></table>
</td> </td>

View File

@ -5551,7 +5551,7 @@ $frame)</code>
<div class="credit"> <div class="credit">
<hr /> <hr />
Documentation generated on Thu, 12 Aug 2010 15:16:03 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> Documentation generated on Sat, 14 Aug 2010 20:52:50 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div> </div>
</td></tr></table> </td></tr></table>
</td> </td>

File diff suppressed because it is too large Load Diff

View File

@ -299,7 +299,7 @@ $type)</code>
<div class="credit"> <div class="credit">
<hr /> <hr />
Documentation generated on Thu, 12 Aug 2010 15:16:02 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> Documentation generated on Sat, 14 Aug 2010 20:52:49 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div> </div>
</td></tr></table> </td></tr></table>
</td> </td>

View File

@ -1377,7 +1377,7 @@ $type)</code>
<div class="credit"> <div class="credit">
<hr /> <hr />
Documentation generated on Thu, 12 Aug 2010 15:16:03 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> Documentation generated on Sat, 14 Aug 2010 20:52:49 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div> </div>
</td></tr></table> </td></tr></table>
</td> </td>

View File

@ -105,7 +105,7 @@ PHP class to creates array representations for 2D barcodes to be used with TCPDF
<div class="credit"> <div class="credit">
<hr /> <hr />
Documentation generated on Thu, 12 Aug 2010 15:16:02 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> Documentation generated on Sat, 14 Aug 2010 20:52:49 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div> </div>
</td></tr></table> </td></tr></table>
</td> </td>

View File

@ -105,7 +105,7 @@ PHP class to creates array representations for common 1D barcodes to be used wit
<div class="credit"> <div class="credit">
<hr /> <hr />
Documentation generated on Thu, 12 Aug 2010 15:16:03 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> Documentation generated on Sat, 14 Aug 2010 20:52:49 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div> </div>
</td></tr></table> </td></tr></table>
</td> </td>

View File

@ -542,7 +542,7 @@ Configuration file for TCPDF.<br /><br /><br /><br />
<div class="credit"> <div class="credit">
<hr /> <hr />
Documentation generated on Thu, 12 Aug 2010 15:16:09 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> Documentation generated on Sat, 14 Aug 2010 20:52:55 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div> </div>
</td></tr></table> </td></tr></table>
</td> </td>

View File

@ -97,7 +97,7 @@ Array of WEB safe colors.<br /><br /><br /><br />
<div class="credit"> <div class="credit">
<hr /> <hr />
Documentation generated on Thu, 12 Aug 2010 15:16:03 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> Documentation generated on Sat, 14 Aug 2010 20:52:50 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div> </div>
</td></tr></table> </td></tr></table>
</td> </td>

View File

@ -157,7 +157,7 @@ Class to create PDF417 barcode arrays for TCPDF class.<br /><br /><p>PDF417 (ISO
<div class="credit"> <div class="credit">
<hr /> <hr />
Documentation generated on Thu, 12 Aug 2010 15:16:03 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> Documentation generated on Sat, 14 Aug 2010 20:52:50 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div> </div>
</td></tr></table> </td></tr></table>
</td> </td>

View File

@ -480,7 +480,7 @@ string $string, [int $split_length = 1])</code>
<div class="credit"> <div class="credit">
<hr /> <hr />
Documentation generated on Thu, 12 Aug 2010 15:16:03 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> Documentation generated on Sat, 14 Aug 2010 20:52:50 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div> </div>
</td></tr></table> </td></tr></table>
</td> </td>

View File

@ -82,7 +82,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> <td><b>author:</b>&nbsp;&nbsp;</td><td>Nicola Asuni</td>
</tr> </tr>
<tr> <tr>
<td><b>version:</b>&nbsp;&nbsp;</td><td>5.8.001</td> <td><b>version:</b>&nbsp;&nbsp;</td><td>5.8.002</td>
</tr> </tr>
<tr> <tr>
<td><b>copyright:</b>&nbsp;&nbsp;</td><td>2002-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com</td> <td><b>copyright:</b>&nbsp;&nbsp;</td><td>2002-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com</td>
@ -113,7 +113,7 @@ unicode data<br /><br /></div>
<div class="tags"> <div class="tags">
<table width="90%" border="0" cellspacing="0" cellpadding="1"><tr><td class="code_border"> <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"> <table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="code">
<code>PDF_PRODUCER = 'TCPDF 5.8.001 (http://www.tcpdf.org)'</code> <code>PDF_PRODUCER = 'TCPDF 5.8.002 (http://www.tcpdf.org)'</code>
</td></tr></table> </td></tr></table>
</td></tr></table> </td></tr></table>
@ -124,7 +124,7 @@ unicode data<br /><br /></div>
<div class="credit"> <div class="credit">
<hr /> <hr />
Documentation generated on Thu, 12 Aug 2010 15:16:04 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> Documentation generated on Sat, 14 Aug 2010 20:52:51 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div> </div>
</td></tr></table> </td></tr></table>
</td> </td>

View File

@ -246,7 +246,7 @@ Unicode data for TCPDF library.<br /><br /><br /><br />
<div class="credit"> <div class="credit">
<hr /> <hr />
Documentation generated on Thu, 12 Aug 2010 15:16:09 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> Documentation generated on Sat, 14 Aug 2010 20:52:55 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div> </div>
</td></tr></table> </td></tr></table>
</td> </td>

View File

@ -851,6 +851,8 @@
<dd>in file qrcode.php, method <a href="com-tecnick-tcpdf/QRcode.html#methodisdigitat">QRcode::isdigitat()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Return true if the character at specified position is a number</dd> <dd>in file qrcode.php, method <a href="com-tecnick-tcpdf/QRcode.html#methodisdigitat">QRcode::isdigitat()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Return true if the character at specified position is a number</dd>
<dt><b>isRTLTextDir</b></dt> <dt><b>isRTLTextDir</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodisRTLTextDir">TCPDF::isRTLTextDir()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Return the current temporary RTL status</dd> <dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodisRTLTextDir">TCPDF::isRTLTextDir()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Return the current temporary RTL status</dd>
<dt><b>isUnicodeFont</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodisUnicodeFont">TCPDF::isUnicodeFont()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Return true if the current font is unicode type.</dd>
<dt><b>isValidCSSSelectorForTag</b></dt> <dt><b>isValidCSSSelectorForTag</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodisValidCSSSelectorForTag">TCPDF::isValidCSSSelectorForTag()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns true if the CSS selector is valid for the selected HTML tag</dd> <dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodisValidCSSSelectorForTag">TCPDF::isValidCSSSelectorForTag()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns true if the CSS selector is valid for the selected HTML tag</dd>
</dl> </dl>
@ -2038,7 +2040,7 @@
<a href="elementindex.html#top">top</a><br> <a href="elementindex.html#top">top</a><br>
<div class="credit"> <div class="credit">
<hr /> <hr />
Documentation generated on Thu, 12 Aug 2010 15:16:02 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> Documentation generated on Sat, 14 Aug 2010 20:52:49 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div> </div>
</td></tr></table> </td></tr></table>
</td> </td>

View File

@ -1045,6 +1045,8 @@
<dd>in file qrcode.php, method <a href="com-tecnick-tcpdf/QRcode.html#methodisdigitat">QRcode::isdigitat()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Return true if the character at specified position is a number</dd> <dd>in file qrcode.php, method <a href="com-tecnick-tcpdf/QRcode.html#methodisdigitat">QRcode::isdigitat()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Return true if the character at specified position is a number</dd>
<dt><b>isRTLTextDir</b></dt> <dt><b>isRTLTextDir</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodisRTLTextDir">TCPDF::isRTLTextDir()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Return the current temporary RTL status</dd> <dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodisRTLTextDir">TCPDF::isRTLTextDir()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Return the current temporary RTL status</dd>
<dt><b>isUnicodeFont</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodisUnicodeFont">TCPDF::isUnicodeFont()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Return true if the current font is unicode type.</dd>
<dt><b>isValidCSSSelectorForTag</b></dt> <dt><b>isValidCSSSelectorForTag</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodisValidCSSSelectorForTag">TCPDF::isValidCSSSelectorForTag()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns true if the CSS selector is valid for the selected HTML tag</dd> <dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodisValidCSSSelectorForTag">TCPDF::isValidCSSSelectorForTag()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns true if the CSS selector is valid for the selected HTML tag</dd>
</dl> </dl>
@ -2070,7 +2072,7 @@
<a href="elementindex_com-tecnick-tcpdf.html#top">top</a><br> <a href="elementindex_com-tecnick-tcpdf.html#top">top</a><br>
<div class="credit"> <div class="credit">
<hr /> <hr />
Documentation generated on Thu, 12 Aug 2010 15:16:02 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> Documentation generated on Sat, 14 Aug 2010 20:52:49 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div> </div>
</td></tr></table> </td></tr></table>
</td> </td>

View File

@ -35,7 +35,7 @@
<a href="#Post-parsing">Post-parsing</a><br> <a href="#Post-parsing">Post-parsing</a><br>
<div class="credit"> <div class="credit">
<hr /> <hr />
Documentation generated on Thu, 12 Aug 2010 15:16:09 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> Documentation generated on Sat, 14 Aug 2010 20:52:55 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div> </div>
</td></tr></table> </td></tr></table>
</td> </td>

View File

@ -67,7 +67,7 @@
This documentation was generated by <a href="http://www.phpdoc.org">phpDocumentor v1.4.3</a><br /> This documentation was generated by <a href="http://www.phpdoc.org">phpDocumentor v1.4.3</a><br />
<div class="credit"> <div class="credit">
<hr /> <hr />
Documentation generated on Thu, 12 Aug 2010 15:16:02 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> Documentation generated on Sat, 14 Aug 2010 20:52:49 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div> </div>
</td></tr></table> </td></tr></table>
</td> </td>

View File

@ -67,7 +67,7 @@
This documentation was generated by <a href="http://www.phpdoc.org">phpDocumentor v1.4.3</a><br /> This documentation was generated by <a href="http://www.phpdoc.org">phpDocumentor v1.4.3</a><br />
<div class="credit"> <div class="credit">
<hr /> <hr />
Documentation generated on Thu, 12 Aug 2010 15:16:02 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> Documentation generated on Sat, 14 Aug 2010 20:52:49 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div> </div>
</td></tr></table> </td></tr></table>
</td> </td>

View File

@ -2,7 +2,7 @@
//============================================================+ //============================================================+
// File name : example_001.php // File name : example_001.php
// Begin : 2008-03-04 // Begin : 2008-03-04
// Last Update : 2010-08-08 // Last Update : 2010-08-14
// //
// Description : Example 001 for TCPDF class // Description : Example 001 for TCPDF class
// Default Header and Footer // Default Header and Footer
@ -84,7 +84,7 @@ $pdf->AddPage();
// Set some content to print // Set some content to print
$html = <<<EOD $html = <<<EOD
<h1>Welcome to <a href="http://www.tcpdf.org" style="text-decoration:none;color:black;"><span style="background-color:#CC0000;"> TC<span style="color:white;">PDF</span> </span></a>!</h1> <h1>Welcome to <a href="http://www.tcpdf.org" style="text-decoration:none;background-color:#CC0000;color:black;">&nbsp;<span style="color:black;">TC</span><span style="color:white;">PDF</span>&nbsp;</a>!</h1>
<i>This is the first example of TCPDF library.</i> <i>This is the first example of TCPDF library.</i>
<p>This text is printed using the <i>writeHTMLCell()</i> method but you can also use: <i>Multicell(), writeHTML(), Write(), Cell() and Text()</i>.</p> <p>This text is printed using the <i>writeHTMLCell()</i> method but you can also use: <i>Multicell(), writeHTML(), Write(), Cell() and Text()</i>.</p>
<p>Please check the source code documentation and other examples for further information.</p> <p>Please check the source code documentation and other examples for further information.</p>

343
tcpdf.php
View File

@ -1,9 +1,9 @@
<?php <?php
//============================================================+ //============================================================+
// File name : tcpdf.php // File name : tcpdf.php
// Version : 5.8.001 // Version : 5.8.002
// Begin : 2002-08-03 // Begin : 2002-08-03
// Last Update : 2010-08-12 // Last Update : 2010-08-14
// Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com // Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) // License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -126,7 +126,7 @@
* @copyright 2002-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com * @copyright 2002-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://www.tcpdf.org * @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL * @license http://www.gnu.org/copyleft/lesser.html LGPL
* @version 5.8.001 * @version 5.8.002
*/ */
/** /**
@ -150,14 +150,14 @@ if (!class_exists('TCPDF', false)) {
/** /**
* define default PDF document producer * define default PDF document producer
*/ */
define('PDF_PRODUCER', 'TCPDF 5.8.001 (http://www.tcpdf.org)'); define('PDF_PRODUCER', 'TCPDF 5.8.002 (http://www.tcpdf.org)');
/** /**
* This is a PHP class for generating PDF documents without requiring external extensions.<br> * 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> * 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 * @name TCPDF
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @version 5.8.001 * @version 5.8.002
* @author Nicola Asuni - info@tecnick.com * @author Nicola Asuni - info@tecnick.com
* @link http://www.tcpdf.org * @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL * @license http://www.gnu.org/copyleft/lesser.html LGPL
@ -1318,14 +1318,14 @@ if (!class_exists('TCPDF', false)) {
* @access protected * @access protected
* @since 4.6.006 (2009-04-28) * @since 4.6.006 (2009-04-28)
*/ */
protected $re_spaces = '/[\s]/'; protected $re_spaces = '/[^\S\xa0]/';
/** /**
* Array of parts $re_spaces * Array of parts $re_spaces
* @access protected * @access protected
* @since 5.5.011 (2010-07-09) * @since 5.5.011 (2010-07-09)
*/ */
protected $re_space = array('p' => '[\s]', 'm' => ''); protected $re_space = array('p' => '[^\S\xa0]', 'm' => '');
/** /**
* Signature object ID * Signature object ID
@ -1822,11 +1822,11 @@ if (!class_exists('TCPDF', false)) {
// \p{Z} or \p{Separator}: any kind of Unicode whitespace or invisible separator. // \p{Z} or \p{Separator}: any kind of Unicode whitespace or invisible separator.
// \p{Lo} or \p{Other_Letter}: a Unicode letter or ideograph that does not have lowercase and uppercase variants. // \p{Lo} or \p{Other_Letter}: a Unicode letter or ideograph that does not have lowercase and uppercase variants.
// \p{Lo} is needed because Chinese characters are packed next to each other without spaces in between. // \p{Lo} is needed because Chinese characters are packed next to each other without spaces in between.
//$this->setSpacesRE('/[\s\p{Z}\p{Lo}]/u'); //$this->setSpacesRE('/[^\S\P{Z}\P{Lo}\xa0]/u');
$this->setSpacesRE('/[\s\p{Z}]/u'); $this->setSpacesRE('/[^\S\P{Z}\xa0]/u');
} else { } else {
// PCRE unicode support is turned OFF // PCRE unicode support is turned OFF
$this->setSpacesRE('/[\s]/'); $this->setSpacesRE('/[^\S\xa0]/');
} }
$this->default_form_prop = array('lineWidth'=>1, 'borderStyle'=>'solid', 'fillColor'=>array(255, 255, 255), 'strokeColor'=>array(128, 128, 128)); $this->default_form_prop = array('lineWidth'=>1, 'borderStyle'=>'solid', 'fillColor'=>array(255, 255, 255), 'strokeColor'=>array(128, 128, 128));
// set file ID for trailer // set file ID for trailer
@ -2825,17 +2825,21 @@ if (!class_exists('TCPDF', false)) {
/** /**
* Set regular expression to detect withespaces or word separators. * Set regular expression to detect withespaces or word separators.
* The pattern delimiter must be the forward-slash character '/'. * The pattern delimiter must be the forward-slash character '/'.
* Some example patterns are:
* <pre> * <pre>
* if PCRE unicode support is turned ON: * Non-Unicode or missing PCRE unicode support: '/[^\S\xa0]/'
* Unicode and PCRE unicode support: '/[^\S\P{Z}\xa0]/u'
* Unicode and PCRE unicode support in Chinese mode: '/[^\S\P{Z}\P{Lo}\xa0]/u'
* if PCRE unicode support is turned ON (\P is the negate class of \p):
* \p{Z} or \p{Separator}: any kind of Unicode whitespace or invisible separator. * \p{Z} or \p{Separator}: any kind of Unicode whitespace or invisible separator.
* \p{Lo} or \p{Other_Letter}: a Unicode letter or ideograph that does not have lowercase and uppercase variants. * \p{Lo} or \p{Other_Letter}: a Unicode letter or ideograph that does not have lowercase and uppercase variants.
* \p{Lo} is needed because Chinese characters are packed next to each other without spaces in between. * \p{Lo} is needed for Chinese characters because are packed next to each other without spaces in between.
* </pre> * </pre>
* @param string $re regular expression (leave empty for default). * @param string $re regular expression (leave empty for default).
* @access public * @access public
* @since 4.6.016 (2009-06-15) * @since 4.6.016 (2009-06-15)
*/ */
public function setSpacesRE($re='/[\s]/') { public function setSpacesRE($re='/[^\S\xa0]/') {
$this->re_spaces = $re; $this->re_spaces = $re;
$re_parts = explode('/', $re); $re_parts = explode('/', $re);
// get pattern parts // get pattern parts
@ -3877,6 +3881,7 @@ if (!class_exists('TCPDF', false)) {
// set margins // set margins
$prev_lMargin = $this->lMargin; $prev_lMargin = $this->lMargin;
$prev_rMargin = $this->rMargin; $prev_rMargin = $this->rMargin;
$prev_cMargin = $this->cMargin;
$this->lMargin = $this->theadMargins['lmargin'] + ($this->pagedim[$this->page]['olm'] - $this->pagedim[$this->theadMargins['page']]['olm']); $this->lMargin = $this->theadMargins['lmargin'] + ($this->pagedim[$this->page]['olm'] - $this->pagedim[$this->theadMargins['page']]['olm']);
$this->rMargin = $this->theadMargins['rmargin'] + ($this->pagedim[$this->page]['orm'] - $this->pagedim[$this->theadMargins['page']]['orm']); $this->rMargin = $this->theadMargins['rmargin'] + ($this->pagedim[$this->page]['orm'] - $this->pagedim[$this->theadMargins['page']]['orm']);
$this->cMargin = $this->theadMargins['cmargin']; $this->cMargin = $this->theadMargins['cmargin'];
@ -3896,6 +3901,7 @@ if (!class_exists('TCPDF', false)) {
$this->lasth = 0; $this->lasth = 0;
$this->lMargin = $prev_lMargin; $this->lMargin = $prev_lMargin;
$this->rMargin = $prev_rMargin; $this->rMargin = $prev_rMargin;
$this->cMargin = $prev_cMargin;
} }
} }
@ -4279,7 +4285,7 @@ if (!class_exists('TCPDF', false)) {
* @since 2.0.0001 (2008-01-07) * @since 2.0.0001 (2008-01-07)
*/ */
public function GetNumChars($s) { public function GetNumChars($s) {
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) { if ($this->isUnicodeFont()) {
return count($this->UTF8StringToArray($s)); return count($this->UTF8StringToArray($s));
} }
return strlen($s); return strlen($s);
@ -5196,14 +5202,14 @@ if (!class_exists('TCPDF', false)) {
// Justification // Justification
$spacewidth = 0; $spacewidth = 0;
if (($align == 'J') AND ($ns > 0)) { if (($align == 'J') AND ($ns > 0)) {
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) { if ($this->isUnicodeFont()) {
// get string width without spaces // get string width without spaces
$width = $this->GetStringWidth(str_replace(' ', '', $txt)); $width = $this->GetStringWidth(str_replace(' ', '', $txt));
// calculate average space width // calculate average space width
$spacewidth = -1000 * ($w - $width - (2 * $this->cMargin)) / ($ns?$ns:1) / $this->FontSize; $spacewidth = -1000 * ($w - $width - (2 * $this->cMargin)) / ($ns?$ns:1) / $this->FontSize;
// set word position to be used with TJ operator // set word position to be used with TJ operator
$txt2 = str_replace(chr(0).chr(32), ') '.sprintf('%.3F', $spacewidth).' (', $txt2); $txt2 = str_replace(chr(0).chr(32), ') '.sprintf('%.3F', $spacewidth).' (', $txt2);
$unicode_justification = true; $unicode_justification = true;
} else { } else {
// get string width // get string width
$width = $txwidth; $width = $txwidth;
@ -5301,7 +5307,7 @@ if (!class_exists('TCPDF', false)) {
} }
} }
// reset word spacing // reset word spacing
if (!(($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) AND ($align == 'J')) { if (!$this->isUnicodeFont() AND ($align == 'J')) {
$rs .= ' BT 0 Tw ET'; $rs .= ' BT 0 Tw ET';
} }
$this->lasth = $h; $this->lasth = $h;
@ -6174,7 +6180,7 @@ if (!class_exists('TCPDF', false)) {
} }
} }
// update string length // update string length
if ((($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) AND ($arabic)) { if ($this->isUnicodeFont() AND ($arabic)) {
// with bidirectional algorithm some chars may be changed affecting the line length // with bidirectional algorithm some chars may be changed affecting the line length
// *** very slow *** // *** very slow ***
$l = $this->GetArrStringWidth($this->utf8Bidi(array_slice($chars, $j, ($i - $j)), '', $this->tmprtl)); $l = $this->GetArrStringWidth($this->utf8Bidi(array_slice($chars, $j, ($i - $j)), '', $this->tmprtl));
@ -6229,7 +6235,7 @@ if (!class_exists('TCPDF', false)) {
} }
} else { } else {
// word wrapping // word wrapping
if ($this->rtl AND (!$firstblock)) { if ($this->rtl AND (!$firstblock) AND ($sep < $i)) {
$endspace = 1; $endspace = 1;
} else { } else {
$endspace = 0; $endspace = 0;
@ -6478,7 +6484,7 @@ if (!class_exists('TCPDF', false)) {
if (isset($iminfo['mime']) AND !empty($iminfo['mime'])) { if (isset($iminfo['mime']) AND !empty($iminfo['mime'])) {
$mime = explode('/', $iminfo['mime']); $mime = explode('/', $iminfo['mime']);
if ((count($mime) > 1) AND ($mime[0] == 'image') AND (!empty($mime[1]))) { if ((count($mime) > 1) AND ($mime[0] == 'image') AND (!empty($mime[1]))) {
$type = trim($mime[1]); $type = strtolower(trim($mime[1]));
} }
} }
if (empty($type)) { if (empty($type)) {
@ -6677,6 +6683,7 @@ if (!class_exists('TCPDF', false)) {
} }
if ($newimage) { if ($newimage) {
//First use of image, get info //First use of image, get info
$type = strtolower($type);
if ($type == '') { if ($type == '') {
$type = $this->getImageFileType($file, $imsize); $type = $this->getImageFileType($file, $imsize);
} elseif ($type == 'jpg') { } elseif ($type == 'jpg') {
@ -10560,8 +10567,8 @@ if (!class_exists('TCPDF', false)) {
*/ */
protected function UTF8ArrToLatin1($unicode) { protected function UTF8ArrToLatin1($unicode) {
global $utf8tolatin; global $utf8tolatin;
if ((!$this->isunicode) OR ($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) { if ((!$this->isunicode) OR $this->isUnicodeFont()) {
return $unicode; // string is not in unicode return $unicode;
} }
$outarr = array(); // array to be returned $outarr = array(); // array to be returned
foreach ($unicode as $char) { foreach ($unicode as $char) {
@ -14519,7 +14526,7 @@ if (!class_exists('TCPDF', false)) {
* @see AliasNbPages(), PageNo(), Footer() * @see AliasNbPages(), PageNo(), Footer()
*/ */
public function getAliasNbPages() { public function getAliasNbPages() {
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) { if ($this->isUnicodeFont()) {
return '{'.$this->AliasNbPages.'}'; return '{'.$this->AliasNbPages.'}';
} }
return $this->AliasNbPages; return $this->AliasNbPages;
@ -14547,7 +14554,7 @@ if (!class_exists('TCPDF', false)) {
* @see AliasNbPages(), PageNo(), Footer() * @see AliasNbPages(), PageNo(), Footer()
*/ */
public function getAliasNumPage() { public function getAliasNumPage() {
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) { if ($this->isUnicodeFont()) {
return '{'.$this->AliasNumPage.'}'; return '{'.$this->AliasNumPage.'}';
} }
return $this->AliasNumPage; return $this->AliasNumPage;
@ -14582,7 +14589,7 @@ if (!class_exists('TCPDF', false)) {
* @since 3.0.000 (2008-03-27) * @since 3.0.000 (2008-03-27)
*/ */
public function getPageGroupAlias() { public function getPageGroupAlias() {
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) { if ($this->isUnicodeFont()) {
return '{'.$this->currpagegroup.'}'; return '{'.$this->currpagegroup.'}';
} }
return $this->currpagegroup; return $this->currpagegroup;
@ -14597,7 +14604,7 @@ if (!class_exists('TCPDF', false)) {
* @since 4.5.000 (2009-01-02) * @since 4.5.000 (2009-01-02)
*/ */
public function getPageNumGroupAlias() { public function getPageNumGroupAlias() {
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) { if ($this->isUnicodeFont()) {
return '{'.str_replace('{nb', '{pnb', $this->currpagegroup).'}'; return '{'.str_replace('{nb', '{pnb', $this->currpagegroup).'}';
} }
return str_replace('{nb', '{pnb', $this->currpagegroup); return str_replace('{nb', '{pnb', $this->currpagegroup);
@ -16758,7 +16765,7 @@ if (!class_exists('TCPDF', false)) {
} }
} }
} }
// remove heade and style blocks // remove head and style blocks
$html = preg_replace('/<head([^\>]*)>(.*?)<\/head>/siU', '', $html); $html = preg_replace('/<head([^\>]*)>(.*?)<\/head>/siU', '', $html);
$html = preg_replace('/<style([^\>]*)>([^\<]*)<\/style>/isU', '', $html); $html = preg_replace('/<style([^\>]*)>([^\<]*)<\/style>/isU', '', $html);
// define block tags // define block tags
@ -16822,12 +16829,15 @@ if (!class_exists('TCPDF', false)) {
$html = preg_replace('/<\/(table|tr|td|th|blockquote|dd|dt|dl|div|dt|h1|h2|h3|h4|h5|h6|hr|li|ol|ul|p)>[\s]+</', '</\\1><', $html); $html = preg_replace('/<\/(table|tr|td|th|blockquote|dd|dt|dl|div|dt|h1|h2|h3|h4|h5|h6|hr|li|ol|ul|p)>[\s]+</', '</\\1><', $html);
$html = preg_replace('/<\/(td|th)>/', '<marker style="font-size:0"/></\\1>', $html); $html = preg_replace('/<\/(td|th)>/', '<marker style="font-size:0"/></\\1>', $html);
$html = preg_replace('/<\/table>([\s]*)<marker style="font-size:0"\/>/', '</table>', $html); $html = preg_replace('/<\/table>([\s]*)<marker style="font-size:0"\/>/', '</table>', $html);
$html = preg_replace('/'.$this->re_space['p'].'*<img/'.$this->re_space['m'], ' <img', $html); $html = preg_replace('/'.$this->re_space['p'].'+<img/'.$this->re_space['m'], chr(32).'<img', $html);
$html = preg_replace('/<img([^\>]*)>/xi', '<img\\1><span><marker style="font-size:0"/></span>', $html); $html = preg_replace('/<img([^\>]*)>/xi', '<img\\1><span><marker style="font-size:0"/></span>', $html);
$html = preg_replace('/<xre/', '<pre', $html); // restore pre tag $html = preg_replace('/<xre/', '<pre', $html); // restore pre tag
$html = preg_replace('/<textarea([^\>]*)>/xi', '<textarea\\1 value="', $html); $html = preg_replace('/<textarea([^\>]*)>/xi', '<textarea\\1 value="', $html);
$html = preg_replace('/<\/textarea>/', '" />', $html); $html = preg_replace('/<\/textarea>/', '" />', $html);
$html = preg_replace('/<li([^\>]*)><\/li>/', '<li\\1>&nbsp;</li>', $html); $html = preg_replace('/<li([^\>]*)><\/li>/', '<li\\1>&nbsp;</li>', $html);
$html = preg_replace('/<li([^\>]*)>'.$this->re_space['p'].'*<img/'.$this->re_space['m'], '<li\\1><font size="1">&nbsp;</font><img', $html);
$html = preg_replace('/<([^\>\/]*)>[\s]/', '<\\1>&nbsp;', $html); // preserve some spaces
$html = preg_replace('/[\s]<\/([^\>]*)>/', '&nbsp;</\\1>', $html); // preserve some spaces
// trim string // trim string
$html = $this->stringTrim($html); $html = $this->stringTrim($html);
// pattern for generic tag // pattern for generic tag
@ -17407,6 +17417,7 @@ if (!class_exists('TCPDF', false)) {
// text // text
$dom[$key]['tag'] = false; $dom[$key]['tag'] = false;
$dom[$key]['block'] = false; $dom[$key]['block'] = false;
$element = str_replace('$nbsp;', $this->unichr(160), $element);
$dom[$key]['value'] = stripslashes($this->unhtmlentities($element)); $dom[$key]['value'] = stripslashes($this->unhtmlentities($element));
$dom[$key]['parent'] = end($level); $dom[$key]['parent'] = end($level);
} }
@ -17425,7 +17436,7 @@ if (!class_exists('TCPDF', false)) {
*/ */
protected function getSpaceString() { protected function getSpaceString() {
$spacestr = chr(32); $spacestr = chr(32);
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) { if ($this->isUnicodeFont()) {
$spacestr = chr(0).chr(32); $spacestr = chr(0).chr(32);
} }
return $spacestr; return $spacestr;
@ -17479,13 +17490,13 @@ if (!class_exists('TCPDF', false)) {
$curfontascent = $this->getFontAscent($curfontname, $curfontstyle, $curfontsize); $curfontascent = $this->getFontAscent($curfontname, $curfontstyle, $curfontsize);
$curfontdescent = $this->getFontDescent($curfontname, $curfontstyle, $curfontsize); $curfontdescent = $this->getFontDescent($curfontname, $curfontstyle, $curfontsize);
$this->newline = true; $this->newline = true;
$newline = true;
$startlinepage = $this->page; $startlinepage = $this->page;
$minstartliney = $this->y; $minstartliney = $this->y;
$maxbottomliney = 0; $maxbottomliney = 0;
$startlinex = $this->x; $startlinex = $this->x;
$startliney = $this->y; $startliney = $this->y;
$yshift = 0; $yshift = 0;
$newline = true;
$loop = 0; $loop = 0;
$curpos = 0; $curpos = 0;
$this_method_vars = array(); $this_method_vars = array();
@ -17883,70 +17894,47 @@ if (!class_exists('TCPDF', false)) {
$tw += ($prevrMargin - $this->rMargin); $tw += ($prevrMargin - $this->rMargin);
} }
$one_space_width = $this->GetStringWidth(chr(32)); $one_space_width = $this->GetStringWidth(chr(32));
$mdiff = abs($tw - $linew); $no = 0; // number of spaces on a line contained on a single block
if ($this->rtl) { // RTL if ($this->isRTLTextDir()) { // RTL
// remove left space if exist // remove left space if exist
$pos1 = $this->revstrpos($pmid, '[('); $pos1 = $this->revstrpos($pmid, '[(');
if ($pos1 > 0) { if ($pos1 > 0) {
$pos1 = intval($pos1); $pos1 = intval($pos1);
$pos2 = intval($this->revstrpos($pmid, '[('.chr(32))); if ($this->isUnicodeFont()) {
$pos3 = intval($this->revstrpos($pmid, '[('.chr(0).chr(32))); $pos2 = intval($this->revstrpos($pmid, '[('.chr(0).chr(32)));
if ($pos1 == $pos3) { $spacelen = 2;
$pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 4)); } else {
} elseif ($pos1 == $pos2) { $pos2 = intval($this->revstrpos($pmid, '[('.chr(32)));
$pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 3)); $spacelen = 1;
} }
} if ($pos1 == $pos2) {
// remove right space if exist $pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 2 + $spacelen));
$pos1 = strpos($pmid, ')]'); if (substr($pmid, $pos1, 4) == '[()]') {
if ($pos1 > 0) { $linew -= $one_space_width;
$pos1 = intval($pos1); } elseif ($pos1 == strpos($pmid, '[(')) {
$pos2 = intval(strpos($pmid, chr(32).')]')) + 1; $no = 1;
$pos3 = intval(strpos($pmid, chr(0).chr(32).')]')) + 2; }
if ($pos1 == $pos3) {
$pmid = substr($pmid, 0, ($pos1 - 2)).substr($pmid, $pos1);
$linew -= $one_space_width;
$mdiff = abs($tw - $linew);
} elseif ($pos1 == $pos2) {
$pmid = substr($pmid, 0, ($pos1 - 1)).substr($pmid, $pos1);
$linew -= $one_space_width;
$mdiff = abs($tw - $linew);
} }
} }
} else { // LTR } else { // LTR
// remove left space if exist
$pos1 = strpos($pmid, '[(');
if ($pos1 > 0) {
$pos1 = intval($pos1);
$pos2 = intval(strpos($pmid, '[('.chr(32)));
$pos3 = intval(strpos($pmid, '[('.chr(0).chr(32)));
if ($pos1 == $pos3) {
$pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 4));
$linew -= $one_space_width;
$mdiff = abs($tw - $linew);
} elseif ($pos1 == $pos2) {
$pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 3));
$linew -= $one_space_width;
$mdiff = abs($tw - $linew);
}
}
// remove right space if exist // remove right space if exist
$pos1 = $this->revstrpos($pmid, ')]'); $pos1 = $this->revstrpos($pmid, ')]');
if ($pos1 > 0) { if ($pos1 > 0) {
$pos1 = intval($pos1); $pos1 = intval($pos1);
$pos2 = intval($this->revstrpos($pmid, chr(32).')]')) + 1; if ($this->isUnicodeFont()) {
$pos3 = intval($this->revstrpos($pmid, chr(0).chr(32).')]')) + 2; $pos2 = intval($this->revstrpos($pmid, chr(0).chr(32).')]')) + 2;
if ($pos1 == $pos3) { $spacelen = 2;
$pmid = substr($pmid, 0, ($pos1 - 2)).substr($pmid, $pos1); } else {
$pos2 = intval($this->revstrpos($pmid, chr(32).')]')) + 1;
$spacelen = 1;
}
if ($pos1 == $pos2) {
$pmid = substr($pmid, 0, ($pos1 - $spacelen)).substr($pmid, $pos1);
$linew -= $one_space_width; $linew -= $one_space_width;
$mdiff = abs($tw - $linew);
} elseif ($pos1 == $pos2) {
$pmid = substr($pmid, 0, ($pos1 - 1)).substr($pmid, $pos1);
$linew -= $one_space_width;
$mdiff = abs($tw - $linew);
} }
} }
} }
$mdiff = ($tw - $linew);
if ($plalign == 'C') { if ($plalign == 'C') {
if ($this->rtl) { if ($this->rtl) {
$t_x = -($mdiff / 2); $t_x = -($mdiff / 2);
@ -17965,7 +17953,7 @@ if (!class_exists('TCPDF', false)) {
// align text on the left // align text on the left
$t_x = -$mdiff; $t_x = -$mdiff;
} }
$ns = 0; // spaces $ns = 0; // number of spaces
$pmidtemp = $pmid; $pmidtemp = $pmid;
// escape special characters // escape special characters
$pmidtemp = preg_replace('/[\\\][\(]/x', '\\#!#OP#!#', $pmidtemp); $pmidtemp = preg_replace('/[\\\][\(]/x', '\\#!#OP#!#', $pmidtemp);
@ -17984,9 +17972,12 @@ if (!class_exists('TCPDF', false)) {
$ns += $lnstring[2][$kk]; $ns += $lnstring[2][$kk];
$lnstring[3][$kk] = $ns; $lnstring[3][$kk] = $ns;
} }
if ($ns == 0) {
$ns = 1;
}
// calculate additional space to add to each existing space // calculate additional space to add to each existing space
$spacewidth = (($tw - $linew) / ($ns?$ns:1)) * $this->k; $spacewidth = ($mdiff / ($ns - $no)) * $this->k;
$spacewidthu = -1000 * (($tw - $linew) + ($ns * $one_space_width)) / ($ns?$ns:1) / $this->FontSize; $spacewidthu = -1000 * ($mdiff + (($ns + $no) * $one_space_width)) / $ns / $this->FontSize;
$nsmax = $ns; $nsmax = $ns;
$ns = 0; $ns = 0;
reset($lnstring); reset($lnstring);
@ -18135,7 +18126,7 @@ if (!class_exists('TCPDF', false)) {
} // end of while } // end of while
// remove markers // remove markers
$pmid = str_replace('x*#!#*x', '', $pmid); $pmid = str_replace('x*#!#*x', '', $pmid);
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) { if ($this->isUnicodeFont()) {
// multibyte characters // multibyte characters
$spacew = $spacewidthu; $spacew = $spacewidthu;
$pmidtemp = $pmid; $pmidtemp = $pmid;
@ -18516,25 +18507,24 @@ if (!class_exists('TCPDF', false)) {
$this->htmlvspace = 0; $this->htmlvspace = 0;
if ((!$this->premode) AND $this->isRTLTextDir()) { if ((!$this->premode) AND $this->isRTLTextDir()) {
// reverse spaces order // reverse spaces order
$len1 = strlen($dom[$key]['value']); $lsp = ''; // left spaces
$lsp = $len1 - strlen($this->stringLeftTrim($dom[$key]['value'])); $rsp = ''; // right spaces
$rsp = $len1 - strlen($this->stringRightTrim($dom[$key]['value'])); if (preg_match('/^('.$this->re_space['p'].'+)/'.$this->re_space['m'], $dom[$key]['value'], $matches)) {
$tmpstr = ''; $lsp = $matches[1];
if ($rsp > 0) {
$tmpstr .= substr($dom[$key]['value'], -$rsp);
} }
$tmpstr .= $this->stringTrim($dom[$key]['value']); if (preg_match('/('.$this->re_space['p'].'+)$/'.$this->re_space['m'], $dom[$key]['value'], $matches)) {
if ($lsp > 0) { $rsp = $matches[1];
$tmpstr .= substr($dom[$key]['value'], 0, $lsp);
} }
$dom[$key]['value'] = $tmpstr; $dom[$key]['value'] = $rsp.$this->stringTrim($dom[$key]['value']).$lsp;
} }
if ($newline) { if ($newline) {
if (!$this->premode) { if (!$this->premode) {
$prelen = strlen($dom[$key]['value']); $prelen = strlen($dom[$key]['value']);
if ($this->isRTLTextDir()) { if ($this->isRTLTextDir()) {
// right trim except non-breaking space
$dom[$key]['value'] = $this->stringRightTrim($dom[$key]['value']); $dom[$key]['value'] = $this->stringRightTrim($dom[$key]['value']);
} else { } else {
// left trim except non-breaking space
$dom[$key]['value'] = $this->stringLeftTrim($dom[$key]['value']); $dom[$key]['value'] = $this->stringLeftTrim($dom[$key]['value']);
} }
$postlen = strlen($dom[$key]['value']); $postlen = strlen($dom[$key]['value']);
@ -18546,6 +18536,8 @@ if (!class_exists('TCPDF', false)) {
$firstblock = true; $firstblock = true;
} else { } else {
$firstblock = false; $firstblock = false;
// replace empty multiple spaces string with a single space
$dom[$key]['value'] = preg_replace('/^'.$this->re_space['p'].'+$/'.$this->re_space['m'], chr(32), $dom[$key]['value']);
} }
$strrest = ''; $strrest = '';
if ($this->rtl) { if ($this->rtl) {
@ -18553,20 +18545,22 @@ if (!class_exists('TCPDF', false)) {
} else { } else {
$this->x += $this->textindent; $this->x += $this->textindent;
} }
if (!empty($this->HREF) AND (isset($this->HREF['url']))) { if (!isset($dom[$key]['trimmed_space']) OR !$dom[$key]['trimmed_space']) {
// HTML <a> Link if (!empty($this->HREF) AND (isset($this->HREF['url']))) {
$hrefcolor = ''; // HTML <a> Link
if (isset($dom[($dom[$key]['parent'])]['fgcolor']) AND ($dom[($dom[$key]['parent'])]['fgcolor'] !== false)) { $hrefcolor = '';
$hrefcolor = $dom[($dom[$key]['parent'])]['fgcolor']; if (isset($dom[($dom[$key]['parent'])]['fgcolor']) AND ($dom[($dom[$key]['parent'])]['fgcolor'] !== false)) {
$hrefcolor = $dom[($dom[$key]['parent'])]['fgcolor'];
}
$hrefstyle = -1;
if (isset($dom[($dom[$key]['parent'])]['fontstyle']) AND ($dom[($dom[$key]['parent'])]['fontstyle'] !== false)) {
$hrefstyle = $dom[($dom[$key]['parent'])]['fontstyle'];
}
$strrest = $this->addHtmlLink($this->HREF['url'], $dom[$key]['value'], $wfill, true, $hrefcolor, $hrefstyle, true);
} else {
// ****** write only until the end of the line and get the rest ******
$strrest = $this->Write($this->lasth, $dom[$key]['value'], '', $wfill, '', false, 0, true, $firstblock, 0);
} }
$hrefstyle = -1;
if (isset($dom[($dom[$key]['parent'])]['fontstyle']) AND ($dom[($dom[$key]['parent'])]['fontstyle'] !== false)) {
$hrefstyle = $dom[($dom[$key]['parent'])]['fontstyle'];
}
$strrest = $this->addHtmlLink($this->HREF['url'], $dom[$key]['value'], $wfill, true, $hrefcolor, $hrefstyle, true);
} else {
// ****** write only until the end of the line and get the rest ******
$strrest = $this->Write($this->lasth, $dom[$key]['value'], '', $wfill, '', false, 0, true, $firstblock, 0);
} }
$this->textindent = 0; $this->textindent = 0;
if (strlen($strrest) > 0) { if (strlen($strrest) > 0) {
@ -18578,14 +18572,13 @@ if (!class_exists('TCPDF', false)) {
} else { } else {
$loop = 0; $loop = 0;
} }
if (!empty($this->HREF) AND (isset($this->HREF['url']))) { $dom[$key]['value'] = $strrest;
$dom[$key]['value'] = $this->stringTrim($strrest); if ($cell) {
} elseif ($this->premode) { if ($this->rtl) {
$dom[$key]['value'] = $strrest; $this->x -= $this->cMargin;
} elseif ($this->isRTLTextDir()) { } else {
$dom[$key]['value'] = $this->stringRightTrim($strrest); $this->x += $this->cMargin;
} else { }
$dom[$key]['value'] = $this->stringLeftTrim($strrest);
} }
if ($loop < 3) { if ($loop < 3) {
--$key; --$key;
@ -18593,13 +18586,6 @@ if (!class_exists('TCPDF', false)) {
} else { } else {
$loop = 0; $loop = 0;
} }
if ($cell) {
if ($this->rtl) {
$this->x -= $this->cMargin;
} else {
$this->x += $this->cMargin;
}
}
} }
++$key; ++$key;
if (isset($dom[$key]['tag']) AND $dom[$key]['tag'] AND (!isset($dom[$key]['opening']) OR !$dom[$key]['opening']) AND isset($dom[($dom[$key]['parent'])]['attribute']['nobr']) AND ($dom[($dom[$key]['parent'])]['attribute']['nobr'] == 'true')) { if (isset($dom[$key]['tag']) AND $dom[$key]['tag'] AND (!isset($dom[$key]['opening']) OR !$dom[$key]['opening']) AND isset($dom[($dom[$key]['parent'])]['attribute']['nobr']) AND ($dom[($dom[$key]['parent'])]['attribute']['nobr'] == 'true')) {
@ -18659,70 +18645,47 @@ if (!class_exists('TCPDF', false)) {
$tw += ($prevrMargin - $this->rMargin); $tw += ($prevrMargin - $this->rMargin);
} }
$one_space_width = $this->GetStringWidth(chr(32)); $one_space_width = $this->GetStringWidth(chr(32));
$mdiff = abs($tw - $linew); $no = 0; // number of spaces on a line contained on a single block
if ($this->rtl) { // RTL if ($this->isRTLTextDir()) { // RTL
// remove left space if exist // remove left space if exist
$pos1 = $this->revstrpos($pmid, '[('); $pos1 = $this->revstrpos($pmid, '[(');
if ($pos1 > 0) { if ($pos1 > 0) {
$pos1 = intval($pos1); $pos1 = intval($pos1);
$pos2 = intval($this->revstrpos($pmid, '[('.chr(32))); if ($this->isUnicodeFont()) {
$pos3 = intval($this->revstrpos($pmid, '[('.chr(0).chr(32))); $pos2 = intval($this->revstrpos($pmid, '[('.chr(0).chr(32)));
if ($pos1 == $pos3) { $spacelen = 2;
$pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 4)); } else {
} elseif ($pos1 == $pos2) { $pos2 = intval($this->revstrpos($pmid, '[('.chr(32)));
$pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 3)); $spacelen = 1;
} }
} if ($pos1 == $pos2) {
// remove right space if exist $pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 2 + $spacelen));
$pos1 = strpos($pmid, ')]'); if (substr($pmid, $pos1, 4) == '[()]') {
if ($pos1 > 0) { $linew -= $one_space_width;
$pos1 = intval($pos1); } elseif ($pos1 == strpos($pmid, '[(')) {
$pos2 = intval(strpos($pmid, chr(32).')]')) + 1; $no = 1;
$pos3 = intval(strpos($pmid, chr(0).chr(32).')]')) + 2; }
if ($pos1 == $pos3) {
$pmid = substr($pmid, 0, ($pos1 - 2)).substr($pmid, $pos1);
$linew -= $one_space_width;
$mdiff = abs($tw - $linew);
} elseif ($pos1 == $pos2) {
$pmid = substr($pmid, 0, ($pos1 - 1)).substr($pmid, $pos1);
$linew -= $one_space_width;
$mdiff = abs($tw - $linew);
} }
} }
} else { // LTR } else { // LTR
// remove left space if exist
$pos1 = strpos($pmid, '[(');
if ($pos1 > 0) {
$pos1 = intval($pos1);
$pos2 = intval(strpos($pmid, '[('.chr(32)));
$pos3 = intval(strpos($pmid, '[('.chr(0).chr(32)));
if ($pos1 == $pos3) {
$pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 4));
$linew -= $one_space_width;
$mdiff = abs($tw - $linew);
} elseif ($pos1 == $pos2) {
$pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 3));
$linew -= $one_space_width;
$mdiff = abs($tw - $linew);
}
}
// remove right space if exist // remove right space if exist
$pos1 = $this->revstrpos($pmid, ')]'); $pos1 = $this->revstrpos($pmid, ')]');
if ($pos1 > 0) { if ($pos1 > 0) {
$pos1 = intval($pos1); $pos1 = intval($pos1);
$pos2 = intval($this->revstrpos($pmid, chr(32).')]')) + 1; if ($this->isUnicodeFont()) {
$pos3 = intval($this->revstrpos($pmid, chr(0).chr(32).')]')) + 2; $pos2 = intval($this->revstrpos($pmid, chr(0).chr(32).')]')) + 2;
if ($pos1 == $pos3) { $spacelen = 2;
$pmid = substr($pmid, 0, ($pos1 - 2)).substr($pmid, $pos1); } else {
$pos2 = intval($this->revstrpos($pmid, chr(32).')]')) + 1;
$spacelen = 1;
}
if ($pos1 == $pos2) {
$pmid = substr($pmid, 0, ($pos1 - $spacelen)).substr($pmid, $pos1);
$linew -= $one_space_width; $linew -= $one_space_width;
$mdiff = abs($tw - $linew);
} elseif ($pos1 == $pos2) {
$pmid = substr($pmid, 0, ($pos1 - 1)).substr($pmid, $pos1);
$linew -= $one_space_width;
$mdiff = abs($tw - $linew);
} }
} }
} }
$mdiff = ($tw - $linew);
if ($plalign == 'C') { if ($plalign == 'C') {
if ($this->rtl) { if ($this->rtl) {
$t_x = -($mdiff / 2); $t_x = -($mdiff / 2);
@ -21268,7 +21231,7 @@ if (!class_exists('TCPDF', false)) {
} else { } else {
// placemark to be replaced with the correct number // placemark to be replaced with the correct number
$pagenum = '{#'.($outline['p']).'}'; $pagenum = '{#'.($outline['p']).'}';
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) { if ($this->isUnicodeFont()) {
$pagenum = '{'.$pagenum.'}'; $pagenum = '{'.$pagenum.'}';
} }
} }
@ -21387,7 +21350,7 @@ if (!class_exists('TCPDF', false)) {
} else { } else {
// placemark to be replaced with the correct number // placemark to be replaced with the correct number
$pagenum = '{#'.($outline['p']).'}'; $pagenum = '{#'.($outline['p']).'}';
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) { if ($this->isUnicodeFont()) {
$pagenum = '{'.$pagenum.'}'; $pagenum = '{'.$pagenum.'}';
} }
} }
@ -22058,41 +22021,55 @@ if (!class_exists('TCPDF', false)) {
/** /**
* Left trim the input string * Left trim the input string
* @param string $str string to trim * @param string $str string to trim
* @param string $replace string that replace spaces.
* @return left trimmed string * @return left trimmed string
* @author Nicola Asuni * @author Nicola Asuni
* @access public * @access public
* @since 5.8.000 (2010-08-11) * @since 5.8.000 (2010-08-11)
*/ */
public function stringLeftTrim($str) { public function stringLeftTrim($str, $replace='') {
return preg_replace('/^'.$this->re_space['p'].'+/'.$this->re_space['m'], '', $str); return preg_replace('/^'.$this->re_space['p'].'+/'.$this->re_space['m'], $replace, $str);
} }
/** /**
* Right trim the input string * Right trim the input string
* @param string $str string to trim * @param string $str string to trim
* @param string $replace string that replace spaces.
* @return right trimmed string * @return right trimmed string
* @author Nicola Asuni * @author Nicola Asuni
* @access public * @access public
* @since 5.8.000 (2010-08-11) * @since 5.8.000 (2010-08-11)
*/ */
public function stringRightTrim($str) { public function stringRightTrim($str, $replace='') {
return preg_replace('/'.$this->re_space['p'].'+$/'.$this->re_space['m'], '', $str); return preg_replace('/'.$this->re_space['p'].'+$/'.$this->re_space['m'], $replace, $str);
} }
/** /**
* Trim the input string * Trim the input string
* @param string $str string to trim * @param string $str string to trim
* @param string $replace string that replace spaces.
* @return trimmed string * @return trimmed string
* @author Nicola Asuni * @author Nicola Asuni
* @access public * @access public
* @since 5.8.000 (2010-08-11) * @since 5.8.000 (2010-08-11)
*/ */
public function stringTrim($str) { public function stringTrim($str, $replace='') {
$str = $this->stringLeftTrim($str); $str = $this->stringLeftTrim($str, $replace);
$str = $this->stringRightTrim($str); $str = $this->stringRightTrim($str, $replace);
return $str; return $str;
} }
/**
* Return true if the current font is unicode type.
* @return true for unicode font, false otherwise.
* @author Nicola Asuni
* @access public
* @since 5.8.002 (2010-08-14)
*/
public function isUnicodeFont() {
return (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0'));
}
// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- // -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
// SVG METHODS // SVG METHODS
// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- // -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-