From 279df4ca9f0cf89a12487d6b9bbb468f490fff19 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 22 Feb 2011 11:12:58 +0100 Subject: [PATCH] 5.9.056 --- CHANGELOG.TXT | 4 ++ README.TXT | 4 +- tcpdf.php | 149 +++++++++++++++++++++++++++++++++----------------- 3 files changed, 104 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index aba0df6..66350bc 100755 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,3 +1,7 @@ +5.9.056 (2011-02-22) + - A bug on fixHTMLCode() method was fixed. + - Automatic line break for HTML was fixed. + 5.9.055 (2011-02-17) - Another bug related to HTML table page break was fixed. diff --git a/README.TXT b/README.TXT index 1e2b9d9..f200a73 100755 --- a/README.TXT +++ b/README.TXT @@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076 ------------------------------------------------------------ Name: TCPDF -Version: 5.9.055 -Release date: 2011-02-17 +Version: 5.9.056 +Release date: 2011-02-22 Author: Nicola Asuni Copyright (c) 2002-2011: diff --git a/tcpdf.php b/tcpdf.php index 62db1b2..267be00 100755 --- a/tcpdf.php +++ b/tcpdf.php @@ -1,9 +1,9 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 5.9.055 + * @version 5.9.056 */ // Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file. @@ -146,7 +146,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.
* @package com.tecnick.tcpdf * @brief PHP class for generating PDF documents without requiring external extensions. - * @version 5.9.055 + * @version 5.9.056 * @author Nicola Asuni - info@tecnick.com */ class TCPDF { @@ -157,7 +157,7 @@ class TCPDF { * Current TCPDF version. * @private */ - private $tcpdf_version = '5.9.055'; + private $tcpdf_version = '5.9.056'; // Protected properties @@ -6589,6 +6589,8 @@ class TCPDF { $shy_replacement_width = $this->GetCharWidth($shy_replacement); // max Y $maxy = $this->y + $maxh - $h - $this->cell_padding['T'] - $this->cell_padding['B']; + // page width + $pw = $w = $this->w - $this->lMargin - $this->rMargin; // calculate remaining line width ($w) if ($this->rtl) { $w = $this->x - $this->lMargin; @@ -6767,56 +6769,95 @@ class TCPDF { } else { $endspace = 0; } - if ($shy) { - // add hypen (minus symbol) at the end of the line - $shy_width = $tmp_shy_replacement_width; - if ($this->rtl) { - $shy_char_left = $tmp_shy_replacement_char; - $shy_char_right = ''; - } else { - $shy_char_left = ''; - $shy_char_right = $tmp_shy_replacement_char; + // check the lenght of the next string + $strrest = $this->UniArrSubString($uchars, ($sep + $endspace)); + $nextstr = preg_split('/'.$this->re_space['p'].'/'.$this->re_space['m'], $this->stringTrim($strrest)); + if (isset($nextstr[0]) AND ($this->GetStringWidth($nextstr[0]) > $pw)) { + // truncate the word because do not fit on a full page width + $tmpstr = $this->UniArrSubString($uchars, $j, $i); + if ($firstline) { + $startx = $this->x; + $tmparr = array_slice($chars, $j, ($i - $j)); + if ($rtlmode) { + $tmparr = $this->utf8Bidi($tmparr, $tmpstr, $this->tmprtl); + } + $linew = $this->GetArrStringWidth($tmparr); + unset($tmparr); + if ($this->rtl) { + $this->endlinex = $startx - $linew; + } else { + $this->endlinex = $startx + $linew; + } + $w = $linew; + $tmpcellpadding = $this->cell_padding; + if ($maxh == 0) { + $this->SetCellPadding(0); + } } + if ($firstblock AND $this->isRTLTextDir()) { + $tmpstr = $this->stringRightTrim($tmpstr); + } + $this->Cell($w, $h, $tmpstr, 0, 1, $align, $fill, $link, $stretch); + unset($tmpstr); + if ($firstline) { + $this->cell_padding = $tmpcellpadding; + return ($this->UniArrSubString($uchars, $i)); + } + $j = $i; + --$i; } else { - $shy_width = 0; - $shy_char_left = ''; - $shy_char_right = ''; - } - $tmpstr = $this->UniArrSubString($uchars, $j, ($sep + $endspace)); - if ($firstline) { - $startx = $this->x; - $tmparr = array_slice($chars, $j, (($sep + $endspace) - $j)); - if ($rtlmode) { - $tmparr = $this->utf8Bidi($tmparr, $tmpstr, $this->tmprtl); - } - $linew = $this->GetArrStringWidth($tmparr); - unset($tmparr); - if ($this->rtl) { - $this->endlinex = $startx - $linew - $shy_width; + // word wrapping + if ($shy) { + // add hypen (minus symbol) at the end of the line + $shy_width = $tmp_shy_replacement_width; + if ($this->rtl) { + $shy_char_left = $tmp_shy_replacement_char; + $shy_char_right = ''; + } else { + $shy_char_left = ''; + $shy_char_right = $tmp_shy_replacement_char; + } } else { - $this->endlinex = $startx + $linew + $shy_width; + $shy_width = 0; + $shy_char_left = ''; + $shy_char_right = ''; } - $w = $linew; - $tmpcellpadding = $this->cell_padding; - if ($maxh == 0) { - $this->SetCellPadding(0); + $tmpstr = $this->UniArrSubString($uchars, $j, ($sep + $endspace)); + if ($firstline) { + $startx = $this->x; + $tmparr = array_slice($chars, $j, (($sep + $endspace) - $j)); + if ($rtlmode) { + $tmparr = $this->utf8Bidi($tmparr, $tmpstr, $this->tmprtl); + } + $linew = $this->GetArrStringWidth($tmparr); + unset($tmparr); + if ($this->rtl) { + $this->endlinex = $startx - $linew - $shy_width; + } else { + $this->endlinex = $startx + $linew + $shy_width; + } + $w = $linew; + $tmpcellpadding = $this->cell_padding; + if ($maxh == 0) { + $this->SetCellPadding(0); + } } + // print the line + if ($firstblock AND $this->isRTLTextDir()) { + $tmpstr = $this->stringRightTrim($tmpstr); + } + $this->Cell($w, $h, $shy_char_left.$tmpstr.$shy_char_right, 0, 1, $align, $fill, $link, $stretch); + unset($tmpstr); + if ($firstline) { + // return the remaining text + $this->cell_padding = $tmpcellpadding; + return ($this->UniArrSubString($uchars, ($sep + $endspace))); + } + $i = $sep; + $sep = -1; + $shy = false; + $j = ($i+1); } - // print the line - if ($firstblock AND $this->isRTLTextDir()) { - $tmpstr = $this->stringRightTrim($tmpstr); - } - $this->Cell($w, $h, $shy_char_left.$tmpstr.$shy_char_right, 0, 1, $align, $fill, $link, $stretch); - unset($tmpstr); - if ($firstline) { - // return the remaining text - $this->cell_padding = $tmpcellpadding; - return ($this->UniArrSubString($uchars, ($sep + $endspace))); - } - $i = $sep; - $sep = -1; - $shy = false; - $j = ($i+1); } // account for margin changes if ((($this->y + $this->lasth) > $this->PageBreakTrigger) AND (!$this->InFooter)) { @@ -17619,7 +17660,11 @@ class TCPDF { $css = str_replace('/**/', '', $css); preg_match('/'; // get the body part @@ -19038,7 +19083,7 @@ class TCPDF { // text $dom[$key]['tag'] = false; $dom[$key]['block'] = false; - $element = str_replace('$nbsp;', $this->unichr(160), $element); + $element = str_replace(' ', $this->unichr(160), $element); $dom[$key]['value'] = stripslashes($this->unhtmlentities($element)); $dom[$key]['parent'] = end($level); $dom[$key]['dir'] = $dom[$dom[$key]['parent']]['dir']; @@ -20353,9 +20398,11 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: } } if (($wadj > 0) AND (($strlinelen + $wadj) >= $cwa)) { + $wadj = 0; $nextstr = preg_split('/'.$this->re_space['p'].'/'.$this->re_space['m'], $dom[$key]['value']); $numblks = count($nextstr); if ($numblks > 1) { + // try to split on blank spaces $wadj = ($cwa - $strlinelen + $this->GetStringWidth($nextstr[($numblks - 1)])); } }