From ada3181408f5903b33a9f477b015dcb15936fef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ondrej=20=C4=8Cerman?= Date: Mon, 12 May 2025 13:29:30 +0200 Subject: [PATCH 1/7] Automatically add destinations from HTML code --- tcpdf.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tcpdf.php b/tcpdf.php index deefe4a2..b5eabd33 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -17427,6 +17427,9 @@ public function writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=fal } } if ($key == $maxel) break; + if ($dom[$key]['tag'] AND $dom[$key]['opening'] AND !empty($dom[$key]['attribute']['id'])) { + $this->setDestination($dom[$key]['attribute']['id']); + } if ($dom[$key]['tag'] AND isset($dom[$key]['attribute']['pagebreak'])) { // check for pagebreak if (($dom[$key]['attribute']['pagebreak'] == 'true') OR ($dom[$key]['attribute']['pagebreak'] == 'left') OR ($dom[$key]['attribute']['pagebreak'] == 'right')) { From c6c328c1cdbc1ad8365b0b3efd6142bd59de0ce9 Mon Sep 17 00:00:00 2001 From: Kristoffer Wiklund Date: Tue, 13 May 2025 14:52:29 +0200 Subject: [PATCH 2/7] Wrong default value when $table_el['old_cell_padding'] is missing --- tcpdf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcpdf.php b/tcpdf.php index 5d98a631..e9718e29 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -20012,7 +20012,7 @@ protected function closeHTMLTagHandler($dom, $key, $cell, $maxbottomliney=0) { } } if (!$in_table_head) { // we are not inside a thead section - $this->cell_padding = isset($table_el['old_cell_padding']) ? $table_el['old_cell_padding'] : null; + $this->cell_padding = isset($table_el['old_cell_padding']) ? $table_el['old_cell_padding'] : array('T' => 0, 'R' => 0, 'B' => 0, 'L' => 0); // reset row height $this->resetLastH(); if (($this->page == ($this->numpages - 1)) AND ($this->pageopen[$this->numpages])) { From 5bb14113f5f8016b52f9700766f604bb8adb6814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ondrej=20=C4=8Cerman?= Date: Mon, 19 May 2025 15:07:46 +0200 Subject: [PATCH 3/7] FIX error for empty hash link --- tcpdf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcpdf.php b/tcpdf.php index 5d98a631..7c2c0772 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -19151,7 +19151,7 @@ protected function openHTMLTagHandler($dom, $key, $cell) { $imglink = ''; if (isset($this->HREF['url']) AND !TCPDF_STATIC::empty_string($this->HREF['url'])) { $imglink = $this->HREF['url']; - if ($imglink[0] == '#' AND is_numeric($imglink[1])) { + if ($imglink[0] == '#' AND isset($imglink[1]) AND is_numeric($imglink[1])) { // convert url to internal link $lnkdata = explode(',', $imglink); if (isset($lnkdata[0])) { From c3ac93a4873a257a49bf1c9aba6d4d8c86e18830 Mon Sep 17 00:00:00 2001 From: tmbenhura Date: Sat, 24 May 2025 21:53:03 +0200 Subject: [PATCH 4/7] Fixed rgba color parsing to rgb components --- include/tcpdf_colors.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/include/tcpdf_colors.php b/include/tcpdf_colors.php index 5a51594c..8c4529af 100644 --- a/include/tcpdf_colors.php +++ b/include/tcpdf_colors.php @@ -275,7 +275,7 @@ public static function convertHTMLColorToDec($hcolor, &$spotc, $defcol=array('R' $color = strtolower($color); // check for javascript color array syntax if (strpos($color, '[') !== false) { - if (preg_match('/[\[][\"\'](t|g|rgb|cmyk)[\"\'][\,]?([0-9\.]*+)[\,]?([0-9\.]*+)[\,]?([0-9\.]*+)[\,]?([0-9\.]*+)[\]]/', $color, $m) > 0) { + if (preg_match('/[\[][\"\'](t|g|rgba|rgb|cmyk)[\"\'][\,]?([0-9\.]*+)[\,]?([0-9\.]*+)[\,]?([0-9\.]*+)[\,]?([0-9\.]*+)[\]]/', $color, $m) > 0) { $returncolor = array(); switch ($m[1]) { case 'cmyk': { @@ -286,7 +286,8 @@ public static function convertHTMLColorToDec($hcolor, &$spotc, $defcol=array('R' $returncolor['K'] = max(0, min(100, (floatval($m[5]) * 100))); break; } - case 'rgb': { + case 'rgb': + case 'rgba': { // RGB $returncolor['R'] = max(0, min(255, (floatval($m[2]) * 255))); $returncolor['G'] = max(0, min(255, (floatval($m[3]) * 255))); @@ -317,6 +318,25 @@ public static function convertHTMLColorToDec($hcolor, &$spotc, $defcol=array('R' if (strlen($color) == 0) { return $defcol; } + // RGBA ARRAY + if (substr($color, 0, 4) == 'rgba') { + $codes = substr($color, 5); + $codes = str_replace(')', '', $codes); + $returncolor = explode(',', $codes); + // remove alpha component + array_pop($returncolor); + foreach ($returncolor as $key => $val) { + if (strpos($val, '%') > 0) { + // percentage + $returncolor[$key] = (255 * intval($val) / 100); + } else { + $returncolor[$key] = intval($val); /* floatize */ + } + // normalize value + $returncolor[$key] = max(0, min(255, $returncolor[$key])); + } + return $returncolor; + } // RGB ARRAY if (substr($color, 0, 3) == 'rgb') { $codes = substr($color, 4); From b3dcbcba59bfe29f34270eb7d8b1ac889ebc7e97 Mon Sep 17 00:00:00 2001 From: tmbenhura Date: Sat, 24 May 2025 21:54:24 +0200 Subject: [PATCH 5/7] Fixed svg fill alpha setting from rgba color --- tcpdf.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tcpdf.php b/tcpdf.php index 5d98a631..f33a853e 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -23479,6 +23479,8 @@ protected function setSVGStyles($svgstyle, $prevsvgstyle, $x=0, $y=0, $w=1, $h=1 $fill_color = TCPDF_COLORS::convertHTMLColorToDec($svgstyle['fill'], $this->spot_colors); if ($svgstyle['fill-opacity'] != 1) { $this->setAlpha($this->alpha['CA'], 'Normal', $svgstyle['fill-opacity'], false); + } elseif (preg_match('/rgba\(\d+%?,\s*\d+%?,\s*\d+%?,\s*(\d+(?:\.\d+)?)\)/i', $svgstyle['fill'], $rgba_matches)) { + $this->setAlpha($this->alpha['CA'], 'Normal', $rgba_matches[1], false); } $this->setFillColorArray($fill_color); if ($svgstyle['fill-rule'] == 'evenodd') { From 151859eda1c0dfb4b00a17024dee81170b60ceb3 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 27 May 2025 18:30:00 +0100 Subject: [PATCH 6/7] Bump version --- CHANGELOG.TXT | 3 +++ VERSION | 2 +- include/tcpdf_static.php | 2 +- tcpdf.php | 8 ++++---- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 6f01c942..775cd54a 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,3 +1,6 @@ +6.9.5 (2025-05-27) + - + 6.9.4 (2025-05-13) - Update donation link. diff --git a/VERSION b/VERSION index c250d84b..e1e5d136 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.9.4 +6.9.5 diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php index 9b3272af..2d89212f 100644 --- a/include/tcpdf_static.php +++ b/include/tcpdf_static.php @@ -55,7 +55,7 @@ class TCPDF_STATIC { * Current TCPDF version. * @private static */ - private static $tcpdf_version = '6.9.4'; + private static $tcpdf_version = '6.9.5'; /** * String alias for total number of pages. diff --git a/tcpdf.php b/tcpdf.php index 5d98a631..f6c4cc68 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -1,9 +1,9 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 6.9.4 + * @version 6.9.5 */ // TCPDF configuration @@ -128,7 +128,7 @@ * 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 6.9.4 + * @version 6.9.5 * @author Nicola Asuni - info@tecnick.com * @IgnoreAnnotation("protected") * @IgnoreAnnotation("public") From 50717eba24f42c2534075c9e9b71433c54890632 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 27 May 2025 18:38:26 +0100 Subject: [PATCH 7/7] Update changelog --- CHANGELOG.TXT | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 775cd54a..0068dc13 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,5 +1,8 @@ 6.9.5 (2025-05-27) - - + - Automatically add destinations from HTML code #804 + - Wrong default value when $table_el['old_cell_padding'] is missing #807 + - Fixed PHP warning when empty hash link for image exists in HTML #809 + - Fix for application of alpha component to SVG RGBA fills #810 6.9.4 (2025-05-13) - Update donation link.