Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.TXT
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
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.

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.9.4
6.9.5
24 changes: 22 additions & 2 deletions include/tcpdf_colors.php
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand All @@ -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)));
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion include/tcpdf_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 11 additions & 6 deletions tcpdf.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
//============================================================+
// File name : tcpdf.php
// Version : 6.9.4
// Version : 6.9.5
// Begin : 2002-08-03
// Last Update : 2025-04-18
// Last Update : 2025-05-27
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// -------------------------------------------------------------------
Expand Down Expand Up @@ -104,7 +104,7 @@
* Tools to encode your unicode fonts are on fonts/utils directory.</p>
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 6.9.4
* @version 6.9.5
*/

// TCPDF configuration
Expand All @@ -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.<br>
* @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")
Expand Down Expand Up @@ -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')) {
Expand Down Expand Up @@ -19151,7 +19154,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])) {
Expand Down Expand Up @@ -20012,7 +20015,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])) {
Expand Down Expand Up @@ -23479,6 +23482,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') {
Expand Down