32
1
mirror of https://github.com/vdm-io/tcpdf.git synced 2024-12-25 17:51:07 +00:00
This commit is contained in:
nicolaasuni 2011-07-16 11:34:37 +02:00
parent 078642c3f6
commit f029fcf70d
3 changed files with 47 additions and 35 deletions

View File

@ -1,3 +1,7 @@
5.9.103 (2011-07-16)
- Alignment of XHTML lines was improved.
- Spell of the "length" word was fixed.
5.9.102 (2011-07-13) 5.9.102 (2011-07-13)
- Methods startLayer() and endLayer() were added to support arbitrary PDF layers. - Methods startLayer() and endLayer() were added to support arbitrary PDF layers.
- Some improvements/fixes for images were added (thanks to Brendan Abbott). - Some improvements/fixes for images were added (thanks to Brendan Abbott).

View File

@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
------------------------------------------------------------ ------------------------------------------------------------
Name: TCPDF Name: TCPDF
Version: 5.9.102 Version: 5.9.103
Release date: 2011-07-13 Release date: 2011-07-16
Author: Nicola Asuni Author: Nicola Asuni
Copyright (c) 2002-2011: Copyright (c) 2002-2011:

View File

@ -1,9 +1,9 @@
<?php <?php
//============================================================+ //============================================================+
// File name : tcpdf.php // File name : tcpdf.php
// Version : 5.9.102 // Version : 5.9.103
// Begin : 2002-08-03 // Begin : 2002-08-03
// Last Update : 2011-07-13 // Last Update : 2011-07-16
// 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 : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3 + YOU CAN'T REMOVE ANY TCPDF COPYRIGHT NOTICE OR LINK FROM THE GENERATED PDF DOCUMENTS. // License : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3 + YOU CAN'T REMOVE ANY TCPDF COPYRIGHT NOTICE OR LINK FROM THE GENERATED PDF DOCUMENTS.
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -136,7 +136,7 @@
* Tools to encode your unicode fonts are on fonts/utils directory.</p> * Tools to encode your unicode fonts are on fonts/utils directory.</p>
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @author Nicola Asuni * @author Nicola Asuni
* @version 5.9.102 * @version 5.9.103
*/ */
// Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file. // Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file.
@ -148,7 +148,7 @@ require_once(dirname(__FILE__).'/config/tcpdf_config.php');
* 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>
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @brief PHP class for generating PDF documents without requiring external extensions. * @brief PHP class for generating PDF documents without requiring external extensions.
* @version 5.9.102 * @version 5.9.103
* @author Nicola Asuni - info@tecnick.com * @author Nicola Asuni - info@tecnick.com
*/ */
class TCPDF { class TCPDF {
@ -159,7 +159,7 @@ class TCPDF {
* Current TCPDF version. * Current TCPDF version.
* @private * @private
*/ */
private $tcpdf_version = '5.9.102'; private $tcpdf_version = '5.9.103';
// Protected properties // Protected properties
@ -6912,7 +6912,7 @@ class TCPDF {
} else { } else {
$endspace = 0; $endspace = 0;
} }
// check the lenght of the next string // check the length of the next string
$strrest = $this->UniArrSubString($uchars, ($sep + $endspace)); $strrest = $this->UniArrSubString($uchars, ($sep + $endspace));
$nextstr = preg_split('/'.$this->re_space['p'].'/'.$this->re_space['m'], $this->stringTrim($strrest)); $nextstr = preg_split('/'.$this->re_space['p'].'/'.$this->re_space['m'], $this->stringTrim($strrest));
if (isset($nextstr[0]) AND ($this->GetStringWidth($nextstr[0]) > $pw)) { if (isset($nextstr[0]) AND ($this->GetStringWidth($nextstr[0]) > $pw)) {
@ -7874,7 +7874,7 @@ class TCPDF {
$icc = array(); $icc = array();
$offset = 0; $offset = 0;
while (($pos = strpos($data, "ICC_PROFILE\0", $offset)) !== false) { while (($pos = strpos($data, "ICC_PROFILE\0", $offset)) !== false) {
// get ICC sequence lenght // get ICC sequence length
$length = ($this->_getUSHORT($data, ($pos - 2)) - 16); $length = ($this->_getUSHORT($data, ($pos - 2)) - 16);
// marker sequence number // marker sequence number
$msn = max(1, ord($data{($pos + 12)})); $msn = max(1, ord($data{($pos + 12)}));
@ -8286,14 +8286,14 @@ class TCPDF {
/** /**
* Ouput input data and compress it if possible. * Ouput input data and compress it if possible.
* @param $data (string) Data to output. * @param $data (string) Data to output.
* @param $lenght (int) Data lenght in bytes. * @param $length (int) Data length in bytes.
* @protected * @protected
* @since 5.9.086 * @since 5.9.086
*/ */
protected function sendOutputData($data, $lenght) { protected function sendOutputData($data, $length) {
if (!isset($_SERVER['HTTP_ACCEPT_ENCODING']) OR empty($_SERVER['HTTP_ACCEPT_ENCODING'])) { if (!isset($_SERVER['HTTP_ACCEPT_ENCODING']) OR empty($_SERVER['HTTP_ACCEPT_ENCODING'])) {
// the content length may vary if the server is using compression // the content length may vary if the server is using compression
header('Content-Length: '.$lenght); header('Content-Length: '.$length);
} }
echo $data; echo $data;
} }
@ -10038,7 +10038,7 @@ class TCPDF {
/** /**
* Returs the checksum of a TTF table. * Returs the checksum of a TTF table.
* @param $table (string) table to check * @param $table (string) table to check
* @param $length (int) lenght of table in bytes * @param $length (int) length of table in bytes
* @return int checksum * @return int checksum
* @author Nicola Asuni * @author Nicola Asuni
* @protected * @protected
@ -10213,7 +10213,7 @@ class TCPDF {
} }
// rebuild a font subset // rebuild a font subset
$font = $this->_getTrueTypeFontSubset($font, $subsetchars); $font = $this->_getTrueTypeFontSubset($font, $subsetchars);
// calculate new font lenght // calculate new font length
$info['length1'] = strlen($font); $info['length1'] = strlen($font);
if ($compressed) { if ($compressed) {
// recompress font // recompress font
@ -11535,7 +11535,7 @@ class TCPDF {
* Line through for rectangular text area. * Line through for rectangular text area.
* @param $x (int) X coordinate * @param $x (int) X coordinate
* @param $y (int) Y coordinate * @param $y (int) Y coordinate
* @param $w (int) line lenght (width) * @param $w (int) line length (width)
* @protected * @protected
* @since 4.9.008 (2009-09-29) * @since 4.9.008 (2009-09-29)
*/ */
@ -12724,8 +12724,8 @@ class TCPDF {
if (!$f) { if (!$f) {
$this->Error('Unable to create temporary key file: '.$tempkeyfile); $this->Error('Unable to create temporary key file: '.$tempkeyfile);
} }
$envelope_lenght = strlen($envelope); $envelope_length = strlen($envelope);
fwrite($f, $envelope, $envelope_lenght); fwrite($f, $envelope, $envelope_length);
fclose($f); fclose($f);
$tempencfile = tempnam(K_PATH_CACHE, 'tmpenc_'); $tempencfile = tempnam(K_PATH_CACHE, 'tmpenc_');
if (!openssl_pkcs7_encrypt($tempkeyfile, $tempencfile, $pubkey['c'], array(), PKCS7_DETACHED | PKCS7_BINARY)) { if (!openssl_pkcs7_encrypt($tempkeyfile, $tempencfile, $pubkey['c'], array(), PKCS7_DETACHED | PKCS7_BINARY)) {
@ -12733,7 +12733,7 @@ class TCPDF {
} }
unlink($tempkeyfile); unlink($tempkeyfile);
// read encryption signature // read encryption signature
$signature = file_get_contents($tempencfile, false, null, $envelope_lenght); $signature = file_get_contents($tempencfile, false, null, $envelope_length);
unlink($tempencfile); unlink($tempencfile);
// extract signature // extract signature
$signature = substr($signature, strpos($signature, 'Content-Disposition')); $signature = substr($signature, strpos($signature, 'Content-Disposition'));
@ -12907,13 +12907,13 @@ class TCPDF {
*/ */
protected function convertHexStringToString($bs) { protected function convertHexStringToString($bs) {
$string = ''; // string to be returned $string = ''; // string to be returned
$bslenght = strlen($bs); $bslength = strlen($bs);
if (($bslenght % 2) != 0) { if (($bslength % 2) != 0) {
// padding // padding
$bs .= '0'; $bs .= '0';
++$bslenght; ++$bslength;
} }
for ($i = 0; $i < $bslenght; $i += 2) { for ($i = 0; $i < $bslength; $i += 2) {
$string .= chr(hexdec($bs{$i}.$bs{($i + 1)})); $string .= chr(hexdec($bs{$i}.$bs{($i + 1)}));
} }
return $string; return $string;
@ -16474,7 +16474,7 @@ class TCPDF {
if (empty($name)) { if (empty($name)) {
$name = $layer; $name = $layer;
} else { } else {
$name = preg_replace('/[^a-zA-Z0-9_]/', '', $name); $name = preg_replace('/[^a-zA-Z0-9_\-]/', '', $name);
} }
$this->pdflayers[] = array('layer' => $layer, 'name' => $name, 'print' => $print, 'view' => $view); $this->pdflayers[] = array('layer' => $layer, 'name' => $name, 'print' => $print, 'view' => $view);
$this->openMarkedContent = true; $this->openMarkedContent = true;
@ -20252,7 +20252,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$tstart = substr($pagebuff, 0, $this->cntmrk[$this->page]); $tstart = substr($pagebuff, 0, $this->cntmrk[$this->page]);
$tend = substr($pagebuff, $this->cntmrk[$this->page]); $tend = substr($pagebuff, $this->cntmrk[$this->page]);
// add line start to current page // add line start to current page
$yshift = $minstartliney - $this->y; $yshift = ($minstartliney - $this->y);
if ($fontaligned) { if ($fontaligned) {
$yshift += ($curfontsize / $this->k); $yshift += ($curfontsize / $this->k);
} }
@ -20318,7 +20318,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$tstart = substr($pagebuff, 0, $this->cntmrk[$this->page]); $tstart = substr($pagebuff, 0, $this->cntmrk[$this->page]);
$tend = substr($pagebuff, $this->cntmrk[$this->page]); $tend = substr($pagebuff, $this->cntmrk[$this->page]);
// add line start to current page // add line start to current page
$yshift = $minstartliney - $this->y; $yshift = ($minstartliney - $this->y);
$try = sprintf('1 0 0 1 0 %.3F cm', ($yshift * $this->k)); $try = sprintf('1 0 0 1 0 %.3F cm', ($yshift * $this->k));
$this->setPageBuffer($this->page, $tstart."\nq\n".$try."\n".$linebeg."\nQ\n".$tend); $this->setPageBuffer($this->page, $tstart."\nq\n".$try."\n".$linebeg."\nQ\n".$tend);
// shift the annotations and links // shift the annotations and links
@ -20350,8 +20350,15 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$this->y += (((($curfontsize * $this->cell_height_ratio) - ($fontsize * $dom[$key]['line-height'])) / $this->k) + $curfontascent - $fontascent - $curfontdescent + $fontdescent) / 2; $this->y += (((($curfontsize * $this->cell_height_ratio) - ($fontsize * $dom[$key]['line-height'])) / $this->k) + $curfontascent - $fontascent - $curfontdescent + $fontdescent) / 2;
} }
if (($dom[$key]['value'] != 'sup') AND ($dom[$key]['value'] != 'sub')) { if (($dom[$key]['value'] != 'sup') AND ($dom[$key]['value'] != 'sub')) {
$minstartliney = min($this->y, $minstartliney); $current_line_align_data = array($key, $minstartliney, $maxbottomliney);
$maxbottomliney = max(($this->y + (($fontsize * $this->cell_height_ratio) / $this->k)), $maxbottomliney); if (isset($line_align_data) AND (($line_align_data[0] == ($key - 1)) OR (($line_align_data[0] == ($key - 2)) AND (isset($dom[($key - 1)])) AND (preg_match('/^([\s]+)$/', $dom[($key - 1)]['value']) > 0)))) {
$minstartliney = min($this->y, $line_align_data[1]);
$maxbottomliney = max(($this->y + (($fontsize * $this->cell_height_ratio) / $this->k)), $line_align_data[2]);
} else {
$minstartliney = min($this->y, $minstartliney);
$maxbottomliney = max(($this->y + (($fontsize * $this->cell_height_ratio) / $this->k)), $maxbottomliney);
}
$line_align_data = $current_line_align_data;
} }
} }
$this->cell_height_ratio = $dom[$key]['line-height']; $this->cell_height_ratio = $dom[$key]['line-height'];
@ -20408,7 +20415,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$fontaligned = false; $fontaligned = false;
// we are at the beginning of a new line // we are at the beginning of a new line
if (isset($startlinex)) { if (isset($startlinex)) {
$yshift = $minstartliney - $startliney; $yshift = ($minstartliney - $startliney);
if (($yshift > 0) OR ($this->page > $startlinepage)) { if (($yshift > 0) OR ($this->page > $startlinepage)) {
$yshift = 0; $yshift = 0;
} }
@ -21312,7 +21319,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
} // end for each $key } // end for each $key
// align the last line // align the last line
if (isset($startlinex)) { if (isset($startlinex)) {
$yshift = $minstartliney - $startliney; $yshift = ($minstartliney - $startliney);
if (($yshift > 0) OR ($this->page > $startlinepage)) { if (($yshift > 0) OR ($this->page > $startlinepage)) {
$yshift = 0; $yshift = 0;
} }
@ -21447,6 +21454,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
} }
} }
$this->y -= $yshift; $this->y -= $yshift;
$yshift = 0;
} }
} }
// restore previous values // restore previous values
@ -24762,8 +24770,8 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
* @param $dictionary (array) Array of words to be returned without applying the hyphenation algoritm. * @param $dictionary (array) Array of words to be returned without applying the hyphenation algoritm.
* @param $leftmin (int) Minimum number of character to leave on the left of the word without applying the hyphens. * @param $leftmin (int) Minimum number of character to leave on the left of the word without applying the hyphens.
* @param $rightmin (int) Minimum number of character to leave on the right of the word without applying the hyphens. * @param $rightmin (int) Minimum number of character to leave on the right of the word without applying the hyphens.
* @param $charmin (int) Minimum word lenght to apply the hyphenation algoritm. * @param $charmin (int) Minimum word length to apply the hyphenation algoritm.
* @param $charmax (int) Maximum lenght of broken piece of word. * @param $charmax (int) Maximum length of broken piece of word.
* @return array text with soft hyphens * @return array text with soft hyphens
* @author Nicola Asuni * @author Nicola Asuni
* @since 4.9.012 (2010-04-12) * @since 4.9.012 (2010-04-12)
@ -24871,8 +24879,8 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
* @param $dictionary (array) Array of words to be returned without applying the hyphenation algoritm. * @param $dictionary (array) Array of words to be returned without applying the hyphenation algoritm.
* @param $leftmin (int) Minimum number of character to leave on the left of the word without applying the hyphens. * @param $leftmin (int) Minimum number of character to leave on the left of the word without applying the hyphens.
* @param $rightmin (int) Minimum number of character to leave on the right of the word without applying the hyphens. * @param $rightmin (int) Minimum number of character to leave on the right of the word without applying the hyphens.
* @param $charmin (int) Minimum word lenght to apply the hyphenation algoritm. * @param $charmin (int) Minimum word length to apply the hyphenation algoritm.
* @param $charmax (int) Maximum lenght of broken piece of word. * @param $charmax (int) Maximum length of broken piece of word.
* @return array text with soft hyphens * @return array text with soft hyphens
* @author Nicola Asuni * @author Nicola Asuni
* @since 4.9.012 (2010-04-12) * @since 4.9.012 (2010-04-12)
@ -26033,7 +26041,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
*/ */
protected function setSVGStyles($svgstyle, $prevsvgstyle, $x=0, $y=0, $w=1, $h=1, $clip_function='', $clip_params=array()) { protected function setSVGStyles($svgstyle, $prevsvgstyle, $x=0, $y=0, $w=1, $h=1, $clip_function='', $clip_params=array()) {
$objstyle = ''; $objstyle = '';
$minlen = (0.01 / $this->k); // minimum acceptable lenght (3 point) $minlen = (0.01 / $this->k); // minimum acceptable length (3 point)
if (!isset($svgstyle['opacity'])) { if (!isset($svgstyle['opacity'])) {
return $objstyle; return $objstyle;
} }
@ -26332,7 +26340,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$ymin = 2147483647; $ymin = 2147483647;
$ymax = 0; $ymax = 0;
$relcoord = false; $relcoord = false;
$minlen = (0.01 / $this->k); // minimum acceptable lenght (3 point) $minlen = (0.01 / $this->k); // minimum acceptable length (3 point)
$firstcmd = true; // used to print first point $firstcmd = true; // used to print first point
// draw curve pieces // draw curve pieces
foreach ($paths as $key => $val) { foreach ($paths as $key => $val) {