Skip to content

Commit fcd0098

Browse files
committed
6.0.080 (2014-05-20)
- Bug item #921 "Fatal error in hyphenateText() function" was fixed. - Bug item #923 "Automatic Hyphenation error" was fixed. - Patch #70 "Augument TCPDFBarcode classes with ability to return raw png image data" was applied.
1 parent 78b7610 commit fcd0098

7 files changed

+89
-40
lines changed

CHANGELOG.TXT

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
6.0.080 (2014-05-20)
2+
- Bug item #921 "Fatal error in hyphenateText() function" was fixed.
3+
- Bug item #923 "Automatic Hyphenation error" was fixed.
4+
- Patch #70 "Augument TCPDFBarcode classes with ability to return raw png image data" was applied.
5+
16
6.0.079 (2014-05-19)
27
- Patch item #69 "Named destinations, HTML internal and external links" was merged.
38
- Bug item #920 "hyphenateText() should not hyphenate the content of style-tags in HTML mode" was fixed.

README.TXT

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
88
------------------------------------------------------------
99

1010
Name: TCPDF
11-
Version: 6.0.079
12-
Release date: 2014-05-19
11+
Version: 6.0.080
12+
Release date: 2014-05-20
1313
Author: Nicola Asuni
1414

1515
Copyright (c) 2002-2014:

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tecnick.com/tcpdf",
3-
"version": "6.0.079",
3+
"version": "6.0.080",
44
"homepage": "http://www.tcpdf.org/",
55
"type": "library",
66
"description": "TCPDF is a PHP class for generating PDF documents.",

include/tcpdf_static.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class TCPDF_STATIC {
5555
* Current TCPDF version.
5656
* @private static
5757
*/
58-
private static $tcpdf_version = '6.0.079';
58+
private static $tcpdf_version = '6.0.080';
5959

6060
/**
6161
* String alias for total number of pages.

tcpdf.php

+21-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22
//============================================================+
33
// File name : tcpdf.php
4-
// Version : 6.0.079
4+
// Version : 6.0.080
55
// Begin : 2002-08-03
6-
// Last Update : 2014-05-19
6+
// Last Update : 2014-05-20
77
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - [email protected]
88
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
99
// -------------------------------------------------------------------
@@ -104,7 +104,7 @@
104104
* Tools to encode your unicode fonts are on fonts/utils directory.</p>
105105
* @package com.tecnick.tcpdf
106106
* @author Nicola Asuni
107-
* @version 6.0.079
107+
* @version 6.0.080
108108
*/
109109

110110
// TCPDF configuration
@@ -128,7 +128,7 @@
128128
* 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>
129129
* @package com.tecnick.tcpdf
130130
* @brief PHP class for generating PDF documents without requiring external extensions.
131-
* @version 6.0.079
131+
* @version 6.0.080
132132
* @author Nicola Asuni - [email protected]
133133
*/
134134
class TCPDF {
@@ -21994,7 +21994,7 @@ protected function hyphenateWord($word, $patterns, $dictionary=array(), $leftmin
2199421994
return TCPDF_FONTS::UTF8StringToArray($dictionary[$word_string], $this->isunicode, $this->CurrentFont);
2199521995
}
2199621996
// surround word with '_' characters
21997-
$tmpword = array_merge(array(95), $word, array(95));
21997+
$tmpword = array_merge(array(46), $word, array(46));
2199821998
$tmpnumchars = $numchars + 2;
2199921999
$maxpos = $tmpnumchars - $charmin;
2200022000
for ($pos = 0; $pos < $maxpos; ++$pos) {
@@ -22006,15 +22006,18 @@ protected function hyphenateWord($word, $patterns, $dictionary=array(), $leftmin
2200622006
$pattern_length = count($pattern);
2200722007
$digits = 1;
2200822008
for ($j = 0; $j < $pattern_length; ++$j) {
22009-
// check if $pattern[$j] is a number
22009+
// check if $pattern[$j] is a number = hyphenation level (only numbers from 1 to 5 are valid)
2201022010
if (($pattern[$j] >= 48) AND ($pattern[$j] <= 57)) {
2201122011
if ($j == 0) {
2201222012
$zero = $pos - 1;
2201322013
} else {
2201422014
$zero = $pos + $j - $digits;
2201522015
}
22016-
if (!isset($hyphenword[$zero]) OR ($hyphenword[$zero] != $pattern[$j])) {
22017-
$hyphenword[$zero] = TCPDF_FONTS::unichr($pattern[$j], $this->isunicode);
22016+
// get hyphenation level
22017+
$level = ($pattern[$j] - 48);
22018+
// if two levels from two different patterns match at the same point, the higher one is selected.
22019+
if (!isset($hyphenword[$zero]) OR ($hyphenword[$zero] < $level)) {
22020+
$hyphenword[$zero] = $level;
2201822021
}
2201922022
++$digits;
2202022023
}
@@ -22025,6 +22028,7 @@ protected function hyphenateWord($word, $patterns, $dictionary=array(), $leftmin
2202522028
$inserted = 0;
2202622029
$maxpos = $numchars - $rightmin;
2202722030
for ($i = $leftmin; $i <= $maxpos; ++$i) {
22031+
// only odd levels indicate allowed hyphenation points
2202822032
if (isset($hyphenword[$i]) AND (($hyphenword[$i] % 2) != 0)) {
2202922033
// 173 = soft hyphen character
2203022034
array_splice($word, $i + $inserted, 0, 173);
@@ -22079,8 +22083,15 @@ public function hyphenateText($text, $patterns, $dictionary=array(), $leftmin=1,
2207922083
// end of HTML tag
2208022084
$intag = false;
2208122085
// check for style tag
22082-
if (empty(array_diff(array_slice($txtarr, -6, 5), array(115, 116, 121, 108, 101)))) { // = 'style'
22083-
if (empty(array_diff(array_slice($txtarr, -7, 1), array(47)))) { // '/' = 47
22086+
$expected = array(115, 116, 121, 108, 101); // = 'style'
22087+
$current = array_slice($txtarr, -6, 5); // last 5 chars
22088+
$compare = array_diff($expected, $current);
22089+
if (empty($compare)) {
22090+
// check if it is a closing tag
22091+
$expected = array(47); // = '/'
22092+
$current = array_slice($txtarr, -7, 1);
22093+
$compare = array_diff($expected, $current);
22094+
if (empty($compare)) {
2208422095
// closing style tag
2208522096
$skip = false;
2208622097
} else {

tcpdf_barcodes_1d.php

+29-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
//============================================================+
33
// File name : tcpdf_barcodes_1d.php
4-
// Version : 1.0.025
4+
// Version : 1.0.026
55
// Begin : 2008-06-09
6-
// Last Update : 2014-04-25
6+
// Last Update : 2014-05-20
77
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - [email protected]
88
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
99
// -------------------------------------------------------------------
10-
// Copyright (C) 2008-2013 Nicola Asuni - Tecnick.com LTD
10+
// Copyright (C) 2008-2014 Nicola Asuni - Tecnick.com LTD
1111
//
1212
// This file is part of TCPDF software library.
1313
//
@@ -37,14 +37,14 @@
3737
* PHP class to creates array representations for common 1D barcodes to be used with TCPDF.
3838
* @package com.tecnick.tcpdf
3939
* @author Nicola Asuni
40-
* @version 1.0.025
40+
* @version 1.0.026
4141
*/
4242

4343
/**
4444
* @class TCPDFBarcode
4545
* PHP class to creates array representations for common 1D barcodes to be used with TCPDF (http://www.tcpdf.org).<br>
4646
* @package com.tecnick.tcpdf
47-
* @version 1.0.025
47+
* @version 1.0.026
4848
* @author Nicola Asuni
4949
*/
5050
class TCPDFBarcode {
@@ -162,6 +162,25 @@ public function getBarcodeHTML($w=2, $h=30, $color='black') {
162162
return $html;
163163
}
164164

165+
/**
166+
* Send a PNG image representation of barcode (requires GD or Imagick library).
167+
* @param $w (int) Width of a single bar element in pixels.
168+
* @param $h (int) Height of a single bar element in pixels.
169+
* @param $color (array) RGB (0-255) foreground color for bar elements (background is transparent).
170+
* @public
171+
*/
172+
public function getBarcodePNG($w=2, $h=30, $color=array(0,0,0)) {
173+
$data = $this->getBarcodePngData($w, $h, $color);
174+
// send headers
175+
header('Content-Type: image/png');
176+
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
177+
header('Pragma: public');
178+
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
179+
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
180+
//header('Content-Length: '.strlen($data));
181+
echo $data;
182+
}
183+
165184
/**
166185
* Return a PNG image representation of barcode (requires GD or Imagick library).
167186
* @param $w (int) Width of a single bar element in pixels.
@@ -170,7 +189,7 @@ public function getBarcodeHTML($w=2, $h=30, $color='black') {
170189
* @return image or false in case of error.
171190
* @public
172191
*/
173-
public function getBarcodePNG($w=2, $h=30, $color=array(0,0,0)) {
192+
public function getBarcodePngData($w=2, $h=30, $color=array(0,0,0)) {
174193
// calculate image size
175194
$width = ($this->barcode_array['maxw'] * $w);
176195
$height = $h;
@@ -208,18 +227,15 @@ public function getBarcodePNG($w=2, $h=30, $color=array(0,0,0)) {
208227
}
209228
$x += $bw;
210229
}
211-
// send headers
212-
header('Content-Type: image/png');
213-
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
214-
header('Pragma: public');
215-
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
216-
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
217230
if ($imagick) {
218231
$png->drawimage($bar);
219-
echo $png;
232+
return $png;
220233
} else {
234+
ob_start();
221235
imagepng($png);
236+
$imagedata = ob_get_clean();
222237
imagedestroy($png);
238+
return $imagedata;
223239
}
224240
}
225241

tcpdf_barcodes_2d.php

+30-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
//============================================================+
33
// File name : tcpdf_barcodes_2d.php
4-
// Version : 1.0.014
4+
// Version : 1.0.015
55
// Begin : 2009-04-07
6-
// Last Update : 2013-03-17
6+
// Last Update : 2014-05-20
77
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - [email protected]
88
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
99
// -------------------------------------------------------------------
10-
// Copyright (C) 2009-2013 Nicola Asuni - Tecnick.com LTD
10+
// Copyright (C) 2009-2014 Nicola Asuni - Tecnick.com LTD
1111
//
1212
// This file is part of TCPDF software library.
1313
//
@@ -37,14 +37,14 @@
3737
* PHP class to creates array representations for 2D barcodes to be used with TCPDF.
3838
* @package com.tecnick.tcpdf
3939
* @author Nicola Asuni
40-
* @version 1.0.014
40+
* @version 1.0.015
4141
*/
4242

4343
/**
4444
* @class TCPDF2DBarcode
4545
* PHP class to creates array representations for 2D barcodes to be used with TCPDF (http://www.tcpdf.org).
4646
* @package com.tecnick.tcpdf
47-
* @version 1.0.014
47+
* @version 1.0.015
4848
* @author Nicola Asuni
4949
*/
5050
class TCPDF2DBarcode {
@@ -162,6 +162,26 @@ public function getBarcodeHTML($w=10, $h=10, $color='black') {
162162
return $html;
163163
}
164164

165+
/**
166+
* Send a PNG image representation of barcode (requires GD or Imagick library).
167+
* @param $w (int) Width of a single rectangle element in pixels.
168+
* @param $h (int) Height of a single rectangle element in pixels.
169+
* @param $color (array) RGB (0-255) foreground color for bar elements (background is transparent).
170+
* @public
171+
*/
172+
public function getBarcodePNG($w=3, $h=3, $color=array(0,0,0)) {
173+
$data = $this->getBarcodePngData($w, $h, $color);
174+
// send headers
175+
header('Content-Type: image/png');
176+
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
177+
header('Pragma: public');
178+
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
179+
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
180+
//header('Content-Length: '.strlen($data));
181+
echo $data;
182+
183+
}
184+
165185
/**
166186
* Return a PNG image representation of barcode (requires GD or Imagick library).
167187
* @param $w (int) Width of a single rectangle element in pixels.
@@ -170,7 +190,7 @@ public function getBarcodeHTML($w=10, $h=10, $color='black') {
170190
* @return image or false in case of error.
171191
* @public
172192
*/
173-
public function getBarcodePNG($w=3, $h=3, $color=array(0,0,0)) {
193+
public function getBarcodePngData($w=3, $h=3, $color=array(0,0,0)) {
174194
// calculate image size
175195
$width = ($this->barcode_array['num_cols'] * $w);
176196
$height = ($this->barcode_array['num_rows'] * $h);
@@ -211,18 +231,15 @@ public function getBarcodePNG($w=3, $h=3, $color=array(0,0,0)) {
211231
}
212232
$y += $h;
213233
}
214-
// send headers
215-
header('Content-Type: image/png');
216-
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
217-
header('Pragma: public');
218-
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
219-
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
220234
if ($imagick) {
221235
$png->drawimage($bar);
222-
echo $png;
236+
return $png;
223237
} else {
238+
ob_start();
224239
imagepng($png);
240+
$imagedata = ob_get_clean();
225241
imagedestroy($png);
242+
return $imagedata;
226243
}
227244
}
228245

0 commit comments

Comments
 (0)