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)
- Bug #3043650 "subsetchars incorrectly cached" was fixed.

View File

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

View File

@ -60,7 +60,7 @@
<div class="credit">
<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>
</td></tr></table>
</td>

View File

@ -1003,7 +1003,7 @@ $code)</code>
<div class="credit">
<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>
</td></tr></table>
</td>

View File

@ -5551,7 +5551,7 @@ $frame)</code>
<div class="credit">
<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>
</td></tr></table>
</td>

File diff suppressed because it is too large Load Diff

View File

@ -299,7 +299,7 @@ $type)</code>
<div class="credit">
<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>
</td></tr></table>
</td>

View File

@ -1377,7 +1377,7 @@ $type)</code>
<div class="credit">
<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>
</td></tr></table>
</td>

View File

@ -105,7 +105,7 @@ PHP class to creates array representations for 2D barcodes to be used with TCPDF
<div class="credit">
<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>
</td></tr></table>
</td>

View File

@ -105,7 +105,7 @@ PHP class to creates array representations for common 1D barcodes to be used wit
<div class="credit">
<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>
</td></tr></table>
</td>

View File

@ -542,7 +542,7 @@ Configuration file for TCPDF.<br /><br /><br /><br />
<div class="credit">
<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>
</td></tr></table>
</td>

View File

@ -97,7 +97,7 @@ Array of WEB safe colors.<br /><br /><br /><br />
<div class="credit">
<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>
</td></tr></table>
</td>

View File

@ -157,7 +157,7 @@ Class to create PDF417 barcode arrays for TCPDF class.<br /><br /><p>PDF417 (ISO
<div class="credit">
<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>
</td></tr></table>
</td>

View File

@ -480,7 +480,7 @@ string $string, [int $split_length = 1])</code>
<div class="credit">
<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>
</td></tr></table>
</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>
</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>
<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">
<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 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>
@ -124,7 +124,7 @@ unicode data<br /><br /></div>
<div class="credit">
<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>
</td></tr></table>
</td>

View File

@ -246,7 +246,7 @@ Unicode data for TCPDF library.<br /><br /><br /><br />
<div class="credit">
<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>
</td></tr></table>
</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>
<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>
<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>
<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>
@ -2038,7 +2040,7 @@
<a href="elementindex.html#top">top</a><br>
<div class="credit">
<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>
</td></tr></table>
</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>
<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>
<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>
<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>
@ -2070,7 +2072,7 @@
<a href="elementindex_com-tecnick-tcpdf.html#top">top</a><br>
<div class="credit">
<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>
</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 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>
</td></tr></table>
</td>

View File

@ -67,7 +67,7 @@
This documentation was generated by <a href="http://www.phpdoc.org">phpDocumentor v1.4.3</a><br />
<div class="credit">
<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>
</td></tr></table>
</td>

View File

@ -67,7 +67,7 @@
This documentation was generated by <a href="http://www.phpdoc.org">phpDocumentor v1.4.3</a><br />
<div class="credit">
<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>
</td></tr></table>
</td>

View File

@ -2,7 +2,7 @@
//============================================================+
// File name : example_001.php
// Begin : 2008-03-04
// Last Update : 2010-08-08
// Last Update : 2010-08-14
//
// Description : Example 001 for TCPDF class
// Default Header and Footer
@ -84,7 +84,7 @@ $pdf->AddPage();
// Set some content to print
$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>
<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>

343
tcpdf.php
View File

@ -1,9 +1,9 @@
<?php
//============================================================+
// File name : tcpdf.php
// Version : 5.8.001
// Version : 5.8.002
// 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
// 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
* @link http://www.tcpdf.org
* @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('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>
* 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 5.8.001
* @version 5.8.002
* @author Nicola Asuni - info@tecnick.com
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
@ -1318,14 +1318,14 @@ if (!class_exists('TCPDF', false)) {
* @access protected
* @since 4.6.006 (2009-04-28)
*/
protected $re_spaces = '/[\s]/';
protected $re_spaces = '/[^\S\xa0]/';
/**
* Array of parts $re_spaces
* @access protected
* @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
@ -1822,11 +1822,11 @@ if (!class_exists('TCPDF', false)) {
// \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} 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}]/u');
//$this->setSpacesRE('/[^\S\P{Z}\P{Lo}\xa0]/u');
$this->setSpacesRE('/[^\S\P{Z}\xa0]/u');
} else {
// 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));
// set file ID for trailer
@ -2825,17 +2825,21 @@ if (!class_exists('TCPDF', false)) {
/**
* Set regular expression to detect withespaces or word separators.
* The pattern delimiter must be the forward-slash character '/'.
* Some example patterns are:
* <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{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>
* @param string $re regular expression (leave empty for default).
* @access public
* @since 4.6.016 (2009-06-15)
*/
public function setSpacesRE($re='/[\s]/') {
public function setSpacesRE($re='/[^\S\xa0]/') {
$this->re_spaces = $re;
$re_parts = explode('/', $re);
// get pattern parts
@ -3877,6 +3881,7 @@ if (!class_exists('TCPDF', false)) {
// set margins
$prev_lMargin = $this->lMargin;
$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->rMargin = $this->theadMargins['rmargin'] + ($this->pagedim[$this->page]['orm'] - $this->pagedim[$this->theadMargins['page']]['orm']);
$this->cMargin = $this->theadMargins['cmargin'];
@ -3896,6 +3901,7 @@ if (!class_exists('TCPDF', false)) {
$this->lasth = 0;
$this->lMargin = $prev_lMargin;
$this->rMargin = $prev_rMargin;
$this->cMargin = $prev_cMargin;
}
}
@ -4279,7 +4285,7 @@ if (!class_exists('TCPDF', false)) {
* @since 2.0.0001 (2008-01-07)
*/
public function GetNumChars($s) {
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) {
if ($this->isUnicodeFont()) {
return count($this->UTF8StringToArray($s));
}
return strlen($s);
@ -5196,14 +5202,14 @@ if (!class_exists('TCPDF', false)) {
// Justification
$spacewidth = 0;
if (($align == 'J') AND ($ns > 0)) {
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) {
// get string width without spaces
$width = $this->GetStringWidth(str_replace(' ', '', $txt));
// calculate average space width
$spacewidth = -1000 * ($w - $width - (2 * $this->cMargin)) / ($ns?$ns:1) / $this->FontSize;
// set word position to be used with TJ operator
$txt2 = str_replace(chr(0).chr(32), ') '.sprintf('%.3F', $spacewidth).' (', $txt2);
$unicode_justification = true;
if ($this->isUnicodeFont()) {
// get string width without spaces
$width = $this->GetStringWidth(str_replace(' ', '', $txt));
// calculate average space width
$spacewidth = -1000 * ($w - $width - (2 * $this->cMargin)) / ($ns?$ns:1) / $this->FontSize;
// set word position to be used with TJ operator
$txt2 = str_replace(chr(0).chr(32), ') '.sprintf('%.3F', $spacewidth).' (', $txt2);
$unicode_justification = true;
} else {
// get string width
$width = $txwidth;
@ -5301,7 +5307,7 @@ if (!class_exists('TCPDF', false)) {
}
}
// 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';
}
$this->lasth = $h;
@ -6174,7 +6180,7 @@ if (!class_exists('TCPDF', false)) {
}
}
// 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
// *** very slow ***
$l = $this->GetArrStringWidth($this->utf8Bidi(array_slice($chars, $j, ($i - $j)), '', $this->tmprtl));
@ -6229,7 +6235,7 @@ if (!class_exists('TCPDF', false)) {
}
} else {
// word wrapping
if ($this->rtl AND (!$firstblock)) {
if ($this->rtl AND (!$firstblock) AND ($sep < $i)) {
$endspace = 1;
} else {
$endspace = 0;
@ -6478,7 +6484,7 @@ if (!class_exists('TCPDF', false)) {
if (isset($iminfo['mime']) AND !empty($iminfo['mime'])) {
$mime = explode('/', $iminfo['mime']);
if ((count($mime) > 1) AND ($mime[0] == 'image') AND (!empty($mime[1]))) {
$type = trim($mime[1]);
$type = strtolower(trim($mime[1]));
}
}
if (empty($type)) {
@ -6677,6 +6683,7 @@ if (!class_exists('TCPDF', false)) {
}
if ($newimage) {
//First use of image, get info
$type = strtolower($type);
if ($type == '') {
$type = $this->getImageFileType($file, $imsize);
} elseif ($type == 'jpg') {
@ -10560,8 +10567,8 @@ if (!class_exists('TCPDF', false)) {
*/
protected function UTF8ArrToLatin1($unicode) {
global $utf8tolatin;
if ((!$this->isunicode) OR ($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) {
return $unicode; // string is not in unicode
if ((!$this->isunicode) OR $this->isUnicodeFont()) {
return $unicode;
}
$outarr = array(); // array to be returned
foreach ($unicode as $char) {
@ -14519,7 +14526,7 @@ if (!class_exists('TCPDF', false)) {
* @see AliasNbPages(), PageNo(), Footer()
*/
public function getAliasNbPages() {
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) {
if ($this->isUnicodeFont()) {
return '{'.$this->AliasNbPages.'}';
}
return $this->AliasNbPages;
@ -14547,7 +14554,7 @@ if (!class_exists('TCPDF', false)) {
* @see AliasNbPages(), PageNo(), Footer()
*/
public function getAliasNumPage() {
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) {
if ($this->isUnicodeFont()) {
return '{'.$this->AliasNumPage.'}';
}
return $this->AliasNumPage;
@ -14582,7 +14589,7 @@ if (!class_exists('TCPDF', false)) {
* @since 3.0.000 (2008-03-27)
*/
public function getPageGroupAlias() {
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) {
if ($this->isUnicodeFont()) {
return '{'.$this->currpagegroup.'}';
}
return $this->currpagegroup;
@ -14597,7 +14604,7 @@ if (!class_exists('TCPDF', false)) {
* @since 4.5.000 (2009-01-02)
*/
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);
@ -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('/<style([^\>]*)>([^\<]*)<\/style>/isU', '', $html);
// 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('/<\/(td|th)>/', '<marker style="font-size:0"/></\\1>', $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('/<xre/', '<pre', $html); // restore pre tag
$html = preg_replace('/<textarea([^\>]*)>/xi', '<textarea\\1 value="', $html);
$html = preg_replace('/<\/textarea>/', '" />', $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
$html = $this->stringTrim($html);
// pattern for generic tag
@ -17407,6 +17417,7 @@ if (!class_exists('TCPDF', false)) {
// text
$dom[$key]['tag'] = false;
$dom[$key]['block'] = false;
$element = str_replace('$nbsp;', $this->unichr(160), $element);
$dom[$key]['value'] = stripslashes($this->unhtmlentities($element));
$dom[$key]['parent'] = end($level);
}
@ -17425,7 +17436,7 @@ if (!class_exists('TCPDF', false)) {
*/
protected function getSpaceString() {
$spacestr = chr(32);
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) {
if ($this->isUnicodeFont()) {
$spacestr = chr(0).chr(32);
}
return $spacestr;
@ -17479,13 +17490,13 @@ if (!class_exists('TCPDF', false)) {
$curfontascent = $this->getFontAscent($curfontname, $curfontstyle, $curfontsize);
$curfontdescent = $this->getFontDescent($curfontname, $curfontstyle, $curfontsize);
$this->newline = true;
$newline = true;
$startlinepage = $this->page;
$minstartliney = $this->y;
$maxbottomliney = 0;
$startlinex = $this->x;
$startliney = $this->y;
$yshift = 0;
$newline = true;
$loop = 0;
$curpos = 0;
$this_method_vars = array();
@ -17883,70 +17894,47 @@ if (!class_exists('TCPDF', false)) {
$tw += ($prevrMargin - $this->rMargin);
}
$one_space_width = $this->GetStringWidth(chr(32));
$mdiff = abs($tw - $linew);
if ($this->rtl) { // RTL
$no = 0; // number of spaces on a line contained on a single block
if ($this->isRTLTextDir()) { // RTL
// remove left space if exist
$pos1 = $this->revstrpos($pmid, '[(');
if ($pos1 > 0) {
$pos1 = intval($pos1);
$pos2 = intval($this->revstrpos($pmid, '[('.chr(32)));
$pos3 = intval($this->revstrpos($pmid, '[('.chr(0).chr(32)));
if ($pos1 == $pos3) {
$pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 4));
} elseif ($pos1 == $pos2) {
$pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 3));
if ($this->isUnicodeFont()) {
$pos2 = intval($this->revstrpos($pmid, '[('.chr(0).chr(32)));
$spacelen = 2;
} else {
$pos2 = intval($this->revstrpos($pmid, '[('.chr(32)));
$spacelen = 1;
}
}
// remove right space if exist
$pos1 = strpos($pmid, ')]');
if ($pos1 > 0) {
$pos1 = intval($pos1);
$pos2 = intval(strpos($pmid, chr(32).')]')) + 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);
if ($pos1 == $pos2) {
$pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 2 + $spacelen));
if (substr($pmid, $pos1, 4) == '[()]') {
$linew -= $one_space_width;
} elseif ($pos1 == strpos($pmid, '[(')) {
$no = 1;
}
}
}
} 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
$pos1 = $this->revstrpos($pmid, ')]');
if ($pos1 > 0) {
$pos1 = intval($pos1);
$pos2 = intval($this->revstrpos($pmid, chr(32).')]')) + 1;
$pos3 = intval($this->revstrpos($pmid, chr(0).chr(32).')]')) + 2;
if ($pos1 == $pos3) {
$pmid = substr($pmid, 0, ($pos1 - 2)).substr($pmid, $pos1);
if ($this->isUnicodeFont()) {
$pos2 = intval($this->revstrpos($pmid, chr(0).chr(32).')]')) + 2;
$spacelen = 2;
} 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;
$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 ($this->rtl) {
$t_x = -($mdiff / 2);
@ -17965,7 +17953,7 @@ if (!class_exists('TCPDF', false)) {
// align text on the left
$t_x = -$mdiff;
}
$ns = 0; // spaces
$ns = 0; // number of spaces
$pmidtemp = $pmid;
// escape special characters
$pmidtemp = preg_replace('/[\\\][\(]/x', '\\#!#OP#!#', $pmidtemp);
@ -17984,9 +17972,12 @@ if (!class_exists('TCPDF', false)) {
$ns += $lnstring[2][$kk];
$lnstring[3][$kk] = $ns;
}
if ($ns == 0) {
$ns = 1;
}
// calculate additional space to add to each existing space
$spacewidth = (($tw - $linew) / ($ns?$ns:1)) * $this->k;
$spacewidthu = -1000 * (($tw - $linew) + ($ns * $one_space_width)) / ($ns?$ns:1) / $this->FontSize;
$spacewidth = ($mdiff / ($ns - $no)) * $this->k;
$spacewidthu = -1000 * ($mdiff + (($ns + $no) * $one_space_width)) / $ns / $this->FontSize;
$nsmax = $ns;
$ns = 0;
reset($lnstring);
@ -18135,7 +18126,7 @@ if (!class_exists('TCPDF', false)) {
} // end of while
// remove markers
$pmid = str_replace('x*#!#*x', '', $pmid);
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) {
if ($this->isUnicodeFont()) {
// multibyte characters
$spacew = $spacewidthu;
$pmidtemp = $pmid;
@ -18516,25 +18507,24 @@ if (!class_exists('TCPDF', false)) {
$this->htmlvspace = 0;
if ((!$this->premode) AND $this->isRTLTextDir()) {
// reverse spaces order
$len1 = strlen($dom[$key]['value']);
$lsp = $len1 - strlen($this->stringLeftTrim($dom[$key]['value']));
$rsp = $len1 - strlen($this->stringRightTrim($dom[$key]['value']));
$tmpstr = '';
if ($rsp > 0) {
$tmpstr .= substr($dom[$key]['value'], -$rsp);
$lsp = ''; // left spaces
$rsp = ''; // right spaces
if (preg_match('/^('.$this->re_space['p'].'+)/'.$this->re_space['m'], $dom[$key]['value'], $matches)) {
$lsp = $matches[1];
}
$tmpstr .= $this->stringTrim($dom[$key]['value']);
if ($lsp > 0) {
$tmpstr .= substr($dom[$key]['value'], 0, $lsp);
if (preg_match('/('.$this->re_space['p'].'+)$/'.$this->re_space['m'], $dom[$key]['value'], $matches)) {
$rsp = $matches[1];
}
$dom[$key]['value'] = $tmpstr;
$dom[$key]['value'] = $rsp.$this->stringTrim($dom[$key]['value']).$lsp;
}
if ($newline) {
if (!$this->premode) {
$prelen = strlen($dom[$key]['value']);
if ($this->isRTLTextDir()) {
// right trim except non-breaking space
$dom[$key]['value'] = $this->stringRightTrim($dom[$key]['value']);
} else {
// left trim except non-breaking space
$dom[$key]['value'] = $this->stringLeftTrim($dom[$key]['value']);
}
$postlen = strlen($dom[$key]['value']);
@ -18546,6 +18536,8 @@ if (!class_exists('TCPDF', false)) {
$firstblock = true;
} else {
$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 = '';
if ($this->rtl) {
@ -18553,20 +18545,22 @@ if (!class_exists('TCPDF', false)) {
} else {
$this->x += $this->textindent;
}
if (!empty($this->HREF) AND (isset($this->HREF['url']))) {
// HTML <a> Link
$hrefcolor = '';
if (isset($dom[($dom[$key]['parent'])]['fgcolor']) AND ($dom[($dom[$key]['parent'])]['fgcolor'] !== false)) {
$hrefcolor = $dom[($dom[$key]['parent'])]['fgcolor'];
if (!isset($dom[$key]['trimmed_space']) OR !$dom[$key]['trimmed_space']) {
if (!empty($this->HREF) AND (isset($this->HREF['url']))) {
// HTML <a> Link
$hrefcolor = '';
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;
if (strlen($strrest) > 0) {
@ -18578,14 +18572,13 @@ if (!class_exists('TCPDF', false)) {
} else {
$loop = 0;
}
if (!empty($this->HREF) AND (isset($this->HREF['url']))) {
$dom[$key]['value'] = $this->stringTrim($strrest);
} elseif ($this->premode) {
$dom[$key]['value'] = $strrest;
} elseif ($this->isRTLTextDir()) {
$dom[$key]['value'] = $this->stringRightTrim($strrest);
} else {
$dom[$key]['value'] = $this->stringLeftTrim($strrest);
$dom[$key]['value'] = $strrest;
if ($cell) {
if ($this->rtl) {
$this->x -= $this->cMargin;
} else {
$this->x += $this->cMargin;
}
}
if ($loop < 3) {
--$key;
@ -18593,13 +18586,6 @@ if (!class_exists('TCPDF', false)) {
} else {
$loop = 0;
}
if ($cell) {
if ($this->rtl) {
$this->x -= $this->cMargin;
} else {
$this->x += $this->cMargin;
}
}
}
++$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')) {
@ -18659,70 +18645,47 @@ if (!class_exists('TCPDF', false)) {
$tw += ($prevrMargin - $this->rMargin);
}
$one_space_width = $this->GetStringWidth(chr(32));
$mdiff = abs($tw - $linew);
if ($this->rtl) { // RTL
$no = 0; // number of spaces on a line contained on a single block
if ($this->isRTLTextDir()) { // RTL
// remove left space if exist
$pos1 = $this->revstrpos($pmid, '[(');
if ($pos1 > 0) {
$pos1 = intval($pos1);
$pos2 = intval($this->revstrpos($pmid, '[('.chr(32)));
$pos3 = intval($this->revstrpos($pmid, '[('.chr(0).chr(32)));
if ($pos1 == $pos3) {
$pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 4));
} elseif ($pos1 == $pos2) {
$pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 3));
if ($this->isUnicodeFont()) {
$pos2 = intval($this->revstrpos($pmid, '[('.chr(0).chr(32)));
$spacelen = 2;
} else {
$pos2 = intval($this->revstrpos($pmid, '[('.chr(32)));
$spacelen = 1;
}
}
// remove right space if exist
$pos1 = strpos($pmid, ')]');
if ($pos1 > 0) {
$pos1 = intval($pos1);
$pos2 = intval(strpos($pmid, chr(32).')]')) + 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);
if ($pos1 == $pos2) {
$pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 2 + $spacelen));
if (substr($pmid, $pos1, 4) == '[()]') {
$linew -= $one_space_width;
} elseif ($pos1 == strpos($pmid, '[(')) {
$no = 1;
}
}
}
} 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
$pos1 = $this->revstrpos($pmid, ')]');
if ($pos1 > 0) {
$pos1 = intval($pos1);
$pos2 = intval($this->revstrpos($pmid, chr(32).')]')) + 1;
$pos3 = intval($this->revstrpos($pmid, chr(0).chr(32).')]')) + 2;
if ($pos1 == $pos3) {
$pmid = substr($pmid, 0, ($pos1 - 2)).substr($pmid, $pos1);
if ($this->isUnicodeFont()) {
$pos2 = intval($this->revstrpos($pmid, chr(0).chr(32).')]')) + 2;
$spacelen = 2;
} 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;
$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 ($this->rtl) {
$t_x = -($mdiff / 2);
@ -21268,7 +21231,7 @@ if (!class_exists('TCPDF', false)) {
} else {
// placemark to be replaced with the correct number
$pagenum = '{#'.($outline['p']).'}';
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) {
if ($this->isUnicodeFont()) {
$pagenum = '{'.$pagenum.'}';
}
}
@ -21387,7 +21350,7 @@ if (!class_exists('TCPDF', false)) {
} else {
// placemark to be replaced with the correct number
$pagenum = '{#'.($outline['p']).'}';
if (($this->CurrentFont['type'] == 'TrueTypeUnicode') OR ($this->CurrentFont['type'] == 'cidfont0')) {
if ($this->isUnicodeFont()) {
$pagenum = '{'.$pagenum.'}';
}
}
@ -22058,41 +22021,55 @@ if (!class_exists('TCPDF', false)) {
/**
* Left trim the input string
* @param string $str string to trim
* @param string $replace string that replace spaces.
* @return left trimmed string
* @author Nicola Asuni
* @access public
* @since 5.8.000 (2010-08-11)
*/
public function stringLeftTrim($str) {
return preg_replace('/^'.$this->re_space['p'].'+/'.$this->re_space['m'], '', $str);
public function stringLeftTrim($str, $replace='') {
return preg_replace('/^'.$this->re_space['p'].'+/'.$this->re_space['m'], $replace, $str);
}
/**
* Right trim the input string
* @param string $str string to trim
* @param string $replace string that replace spaces.
* @return right trimmed string
* @author Nicola Asuni
* @access public
* @since 5.8.000 (2010-08-11)
*/
public function stringRightTrim($str) {
return preg_replace('/'.$this->re_space['p'].'+$/'.$this->re_space['m'], '', $str);
public function stringRightTrim($str, $replace='') {
return preg_replace('/'.$this->re_space['p'].'+$/'.$this->re_space['m'], $replace, $str);
}
/**
* Trim the input string
* @param string $str string to trim
* @param string $replace string that replace spaces.
* @return trimmed string
* @author Nicola Asuni
* @access public
* @since 5.8.000 (2010-08-11)
*/
public function stringTrim($str) {
$str = $this->stringLeftTrim($str);
$str = $this->stringRightTrim($str);
public function stringTrim($str, $replace='') {
$str = $this->stringLeftTrim($str, $replace);
$str = $this->stringRightTrim($str, $replace);
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
// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-