From d7a90bb1dcb990ab2b4a63314f2c7a35f52c891f Mon Sep 17 00:00:00 2001 From: Daniel Salerno Date: Wed, 7 Jun 2023 09:57:21 +0200 Subject: [PATCH 1/3] Fix non-numeric value warning Fixes this warning on generating PDF: Warning: A non-numeric value encountered in /tcpdf/tcpdf.php on line 5473 --- tcpdf.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tcpdf.php b/tcpdf.php index 667b004f..8057f31f 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -5467,6 +5467,9 @@ protected function getCellCode($w, $h=0, $txt='', $border=0, $ln=0, $align='', $ $s .= 'q '.$this->TextColor.' '; } // rendering mode + if(!is_numeric($this->textstrokewidth)){ + $this->textstrokewidth = 0; + } $s .= sprintf('BT %d Tr %F w ET ', $this->textrendermode, ($this->textstrokewidth * $this->k)); // count number of spaces $ns = substr_count($txt, chr(32)); From a247704df0833ebd3c654a05a8243922a3495f0e Mon Sep 17 00:00:00 2001 From: Daniel Salerno Date: Wed, 7 Jun 2023 16:16:20 +0200 Subject: [PATCH 2/3] Better fix for non-numeric value warning Fixes this warning on generating PDF after calling `Text` with a non-numeric value for `$fstroke`: Warning: A non-numeric value encountered in /tcpdf/tcpdf.php on line 5470 --- tcpdf.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tcpdf.php b/tcpdf.php index 8057f31f..06bdd9c8 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -5467,9 +5467,6 @@ protected function getCellCode($w, $h=0, $txt='', $border=0, $ln=0, $align='', $ $s .= 'q '.$this->TextColor.' '; } // rendering mode - if(!is_numeric($this->textstrokewidth)){ - $this->textstrokewidth = 0; - } $s .= sprintf('BT %d Tr %F w ET ', $this->textrendermode, ($this->textstrokewidth * $this->k)); // count number of spaces $ns = substr_count($txt, chr(32)); @@ -22058,7 +22055,7 @@ public function getNumberOfColumns() { public function setTextRenderingMode($stroke=0, $fill=true, $clip=false) { // Ref.: PDF 32000-1:2008 - 9.3.6 Text Rendering Mode // convert text rendering parameters - if ($stroke < 0) { + if ($stroke < 0 or !is_numeric($stroke)) { $stroke = 0; } if ($fill === true) { From 9c7d929b815e42419b588ad3243e6a3c4bf99d34 Mon Sep 17 00:00:00 2001 From: Daniel Salerno Date: Wed, 7 Jun 2023 17:30:55 +0200 Subject: [PATCH 3/3] Update tcpdf.php Co-authored-by: William Desportes --- tcpdf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcpdf.php b/tcpdf.php index 06bdd9c8..c036809c 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -22055,7 +22055,7 @@ public function getNumberOfColumns() { public function setTextRenderingMode($stroke=0, $fill=true, $clip=false) { // Ref.: PDF 32000-1:2008 - 9.3.6 Text Rendering Mode // convert text rendering parameters - if ($stroke < 0 or !is_numeric($stroke)) { + if ($stroke < 0 || !is_numeric($stroke)) { $stroke = 0; } if ($fill === true) {