From b369129642a9cd4605f29118b293f4b8d5360f0e Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Tue, 15 Dec 2020 16:51:44 +0000 Subject: [PATCH 1/2] MDL-70294 libraries: upgrade to version 6.3.5 of TCPDF. --- lib/tcpdf/README.md | 2 +- lib/tcpdf/composer.json | 4 +- lib/tcpdf/include/tcpdf_static.php | 28 +++++++++++-- lib/tcpdf/tcpdf.php | 63 +++++++++++++++++------------- 4 files changed, 63 insertions(+), 34 deletions(-) diff --git a/lib/tcpdf/README.md b/lib/tcpdf/README.md index 734b9879faa..db0149f69cb 100644 --- a/lib/tcpdf/README.md +++ b/lib/tcpdf/README.md @@ -6,7 +6,7 @@ * **category** Library * **author** Nicola Asuni -* **copyright** 2002-2019 Nicola Asuni - Tecnick.com LTD +* **copyright** 2002-2020 Nicola Asuni - Tecnick.com LTD * **license** http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * **link** http://www.tcpdf.org * **source** https://github.com/tecnickcom/TCPDF diff --git a/lib/tcpdf/composer.json b/lib/tcpdf/composer.json index c16c7428cca..2299c976477 100644 --- a/lib/tcpdf/composer.json +++ b/lib/tcpdf/composer.json @@ -1,6 +1,6 @@ { "name": "tecnickcom/tcpdf", - "version": "6.3.2", + "version": "6.3.5", "homepage": "http://www.tcpdf.org/", "type": "library", "description": "TCPDF is a PHP class for generating PDF documents and barcodes.", @@ -13,7 +13,7 @@ "pdf417", "barcodes" ], - "license": "LGPL-3.0", + "license": "LGPL-3.0-only", "authors": [ { "name": "Nicola Asuni", diff --git a/lib/tcpdf/include/tcpdf_static.php b/lib/tcpdf/include/tcpdf_static.php index 7d2c1f54a3d..0139dbe9bea 100644 --- a/lib/tcpdf/include/tcpdf_static.php +++ b/lib/tcpdf/include/tcpdf_static.php @@ -1,9 +1,9 @@ setImageBuffer($file, $info); } // set alignment + $this->img_rb_x = $x + $w; $this->img_rb_y = $y + $h; + // set alignment - if ($this->rtl) { - if ($palign == 'L') { - $ximg = $this->lMargin; - } elseif ($palign == 'C') { - $ximg = ($this->w + $this->lMargin - $this->rMargin - $w) / 2; - } elseif ($palign == 'R') { - $ximg = $this->w - $this->rMargin - $w; - } else { - $ximg = $x - $w; - } - $this->img_rb_x = $ximg; + if ($palign == 'L') { + $ximg = $this->lMargin; + } elseif ($palign == 'C') { + $ximg = ($this->w + $this->lMargin - $this->rMargin - $w) / 2; + } elseif ($palign == 'R') { + $ximg = $this->w - $this->rMargin - $w; } else { - if ($palign == 'L') { - $ximg = $this->lMargin; - } elseif ($palign == 'C') { - $ximg = ($this->w + $this->lMargin - $this->rMargin - $w) / 2; - } elseif ($palign == 'R') { - $ximg = $this->w - $this->rMargin - $w; - } else { - $ximg = $x; - } - $this->img_rb_x = $ximg + $w; + $ximg = $x; } + if ($ismask OR $hidden) { // image is not displayed return $info['i']; @@ -7799,7 +7788,7 @@ class TCPDF { if (isset($this->imagekeys)) { foreach($this->imagekeys as $file) { if (strpos($file, K_PATH_CACHE) === 0) { - unlink($file); + @unlink($file); } } } @@ -7811,6 +7800,7 @@ class TCPDF { 'bufferlen', 'buffer', 'cached_files', + 'imagekeys', 'sign', 'signature_data', 'signature_max_length', @@ -9640,6 +9630,16 @@ class TCPDF { $xmp .= "\t\t\t\t\t\t".'http://ns.adobe.com/pdf/1.3/'."\n"; $xmp .= "\t\t\t\t\t\t".'pdf'."\n"; $xmp .= "\t\t\t\t\t\t".'Adobe PDF Schema'."\n"; + $xmp .= "\t\t\t\t\t\t".''."\n"; + $xmp .= "\t\t\t\t\t\t\t".''."\n"; + $xmp .= "\t\t\t\t\t\t\t\t".''."\n"; + $xmp .= "\t\t\t\t\t\t\t\t\t".'internal'."\n"; + $xmp .= "\t\t\t\t\t\t\t\t\t".'Adobe PDF Schema'."\n"; + $xmp .= "\t\t\t\t\t\t\t\t\t".'InstanceID'."\n"; + $xmp .= "\t\t\t\t\t\t\t\t\t".'URI'."\n"; + $xmp .= "\t\t\t\t\t\t\t\t".''."\n"; + $xmp .= "\t\t\t\t\t\t\t".''."\n"; + $xmp .= "\t\t\t\t\t\t".''."\n"; $xmp .= "\t\t\t\t\t".''."\n"; $xmp .= "\t\t\t\t\t".''."\n"; $xmp .= "\t\t\t\t\t\t".'http://ns.adobe.com/xap/1.0/mm/'."\n"; @@ -12281,7 +12281,7 @@ class TCPDF { $x = $this->w; } $fixed = false; - if (!empty($page) AND ($page[0] == '*')) { + if (!empty($page) AND (substr($page, 0, 1) == '*')) { $page = intval(substr($page, 1)); // this page number will not be changed when moving/add/deleting pages $fixed = true; @@ -12384,7 +12384,8 @@ class TCPDF { $x = $this->w; } $fixed = false; - if (!empty($page) AND ($page[0] == '*')) { + $pageAsString = (string) $page; + if ($pageAsString && $pageAsString[0] == '*') { $page = intval(substr($page, 1)); // this page number will not be changed when moving/add/deleting pages $fixed = true; @@ -23408,7 +23409,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: */ protected function SVGPath($d, $style='') { if ($this->state != 2) { - return; + return; } // set fill/stroke style $op = TCPDF_STATIC::getPathPaintOperator($style, ''); @@ -23428,6 +23429,8 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: $xmax = 0; $ymin = 2147483647; $ymax = 0; + $xinitial = 0; + $yinitial = 0; $relcoord = false; $minlen = (0.01 / $this->k); // minimum acceptable length (3 point) $firstcmd = true; // used to print first point @@ -23472,6 +23475,8 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: if ($ck == 1) { $this->_outPoint($x, $y); $firstcmd = false; + $xinitial = $x; + $yinitial = $y; } else { $this->_outLine($x, $y); } @@ -23659,8 +23664,8 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: if ((($ck + 1) % 7) == 0) { $x0 = $x; $y0 = $y; - $rx = abs($params[($ck - 6)]); - $ry = abs($params[($ck - 5)]); + $rx = max(abs($params[($ck - 6)]), .000000001); + $ry = max(abs($params[($ck - 5)]), .000000001); $ang = -$rawparams[($ck - 4)]; $angle = deg2rad($ang); $fa = $rawparams[($ck - 3)]; // large-arc-flag @@ -23747,6 +23752,8 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: } case 'Z': { $this->_out('h'); + $x = $x0 = $xinitial; + $y = $y0 = $yinitial; break; } } From 48cbfcc87b5e0702063768b4e9bc667c29bc4b1f Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Mon, 18 Jan 2021 21:05:05 +0000 Subject: [PATCH 2/2] MDL-70294 libraries: document upgrade of TCPDF. --- lib/tcpdf/readme_moodle.txt | 13 ++++++------- lib/thirdpartylibs.xml | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/tcpdf/readme_moodle.txt b/lib/tcpdf/readme_moodle.txt index ee3863a6b04..c7d88e9ac51 100644 --- a/lib/tcpdf/readme_moodle.txt +++ b/lib/tcpdf/readme_moodle.txt @@ -1,15 +1,9 @@ -Description of TCPDF library import 6.3.2 +Description of TCPDF library import 6.3.5 ========================================== * download library from https://github.com/tecnickcom/TCPDF/releases * delete examples/, tools/ VERSION and tcpdf_import.php * remove tcpdf_import.php from composer.json * remove all fonts that were not already present -* Re-apply the following commits if they are not included in the upstream version imported: - (and remove them from here once they are verified to be part of the upstream library) - * 18dabac - https://git.io/JeKfU - * 60c9db7 - https://git.io/JeKfT - * 1adcd76 - https://git.io/JeKft - * 5e4d999 - https://git.io/JvrxB * visit http://127.0.0.1/lib/tests/other/pdflibtestpage.php and view the pdf Important @@ -17,6 +11,11 @@ Important A new version of the libray is being developed @ https://github.com/tecnickcom/tc-lib-pdf . Check periodically when it's ready and if it's a drop-in replacement for the legacy tcpdf one. +2020/12/15 +---------- +Upgrade to tcpdf TCPDF 6.3.5 (MDL-70294) +by Paul Holden + 2019/10/20 ---------- Upgrade to tcpdf TCPDF 6.3.2 (MDL-66966) diff --git a/lib/thirdpartylibs.xml b/lib/thirdpartylibs.xml index 768a7af3d57..fab29c184fe 100644 --- a/lib/thirdpartylibs.xml +++ b/lib/thirdpartylibs.xml @@ -116,8 +116,8 @@ tcpdf TCPDF LGPL - 6.3.2 - 3 + 6.3.5 + 3.0-only typo3