Skip to content

Commit

Permalink
MDL-70294 libraries: upgrade to version 6.3.5 of TCPDF.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulholden committed Jan 18, 2021
1 parent c381757 commit b559600
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 34 deletions.
2 changes: 1 addition & 1 deletion lib/tcpdf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

* **category** Library
* **author** Nicola Asuni <[email protected]>
* **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
Expand Down
4 changes: 2 additions & 2 deletions lib/tcpdf/composer.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand All @@ -13,7 +13,7 @@
"pdf417",
"barcodes"
],
"license": "LGPL-3.0",
"license": "LGPL-3.0-only",
"authors": [
{
"name": "Nicola Asuni",
Expand Down
28 changes: 25 additions & 3 deletions lib/tcpdf/include/tcpdf_static.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
//============================================================+
// File name : tcpdf_static.php
// Version : 1.1.3
// Version : 1.1.4
// Begin : 2002-08-03
// Last Update : 2015-04-28
// Last Update : 2019-11-01
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - [email protected]
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// -------------------------------------------------------------------
Expand Down Expand Up @@ -55,7 +55,7 @@ class TCPDF_STATIC {
* Current TCPDF version.
* @private static
*/
private static $tcpdf_version = '6.3.2';
private static $tcpdf_version = '6.3.5';

/**
* String alias for total number of pages.
Expand Down Expand Up @@ -1829,6 +1829,8 @@ public static function fopenLocal($filename, $mode) {
*/
public static function url_exists($url) {
$crs = curl_init();
// encode query params in URL to get right response form the server
$url = self::encodeUrlQuery($url);
curl_setopt($crs, CURLOPT_URL, $url);
curl_setopt($crs, CURLOPT_NOBODY, true);
curl_setopt($crs, CURLOPT_FAILONERROR, true);
Expand All @@ -1846,6 +1848,26 @@ public static function url_exists($url) {
return ($code == 200);
}

/**
* Encode query params in URL
*
* @param string $url
* @return string
* @since 6.3.3 (2019-11-01)
* @public static
*/
public static function encodeUrlQuery($url) {
$urlData = parse_url($url);
if (isset($urlData['query']) && $urlData['query']) {
$urlQueryData = [];
parse_str(urldecode($urlData['query']), $urlQueryData);
$updatedUrl = $urlData['scheme'] . '://' . $urlData['host'] . $urlData['path'] . '?' . http_build_query($urlQueryData);
} else {
$updatedUrl = $url;
}
return $updatedUrl;
}

/**
* Wrapper for file_exists.
* Checks whether a file or directory exists.
Expand Down
63 changes: 35 additions & 28 deletions lib/tcpdf/tcpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -4722,7 +4722,7 @@ public function AddLink() {
*/
public function SetLink($link, $y=0, $page=-1) {
$fixed = false;
if (!empty($page) AND is_string($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;
Expand Down Expand Up @@ -7165,31 +7165,20 @@ public function Image($file, $x='', $y='', $w=0, $h=0, $type='', $link='', $alig
$info['i'] = $this->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'];
Expand Down Expand Up @@ -7799,7 +7788,7 @@ public function _destroy($destroyall=false, $preserve_objcopy=false) {
if (isset($this->imagekeys)) {
foreach($this->imagekeys as $file) {
if (strpos($file, K_PATH_CACHE) === 0) {
unlink($file);
@unlink($file);
}
}
}
Expand All @@ -7811,6 +7800,7 @@ public function _destroy($destroyall=false, $preserve_objcopy=false) {
'bufferlen',
'buffer',
'cached_files',
'imagekeys',
'sign',
'signature_data',
'signature_max_length',
Expand Down Expand Up @@ -9640,6 +9630,16 @@ protected function _putXMP() {
$xmp .= "\t\t\t\t\t\t".'<pdfaSchema:namespaceURI>http://ns.adobe.com/pdf/1.3/</pdfaSchema:namespaceURI>'."\n";
$xmp .= "\t\t\t\t\t\t".'<pdfaSchema:prefix>pdf</pdfaSchema:prefix>'."\n";
$xmp .= "\t\t\t\t\t\t".'<pdfaSchema:schema>Adobe PDF Schema</pdfaSchema:schema>'."\n";
$xmp .= "\t\t\t\t\t\t".'<pdfaSchema:property>'."\n";
$xmp .= "\t\t\t\t\t\t\t".'<rdf:Seq>'."\n";
$xmp .= "\t\t\t\t\t\t\t\t".'<rdf:li rdf:parseType="Resource">'."\n";
$xmp .= "\t\t\t\t\t\t\t\t\t".'<pdfaProperty:category>internal</pdfaProperty:category>'."\n";
$xmp .= "\t\t\t\t\t\t\t\t\t".'<pdfaProperty:description>Adobe PDF Schema</pdfaProperty:description>'."\n";
$xmp .= "\t\t\t\t\t\t\t\t\t".'<pdfaProperty:name>InstanceID</pdfaProperty:name>'."\n";
$xmp .= "\t\t\t\t\t\t\t\t\t".'<pdfaProperty:valueType>URI</pdfaProperty:valueType>'."\n";
$xmp .= "\t\t\t\t\t\t\t\t".'</rdf:li>'."\n";
$xmp .= "\t\t\t\t\t\t\t".'</rdf:Seq>'."\n";
$xmp .= "\t\t\t\t\t\t".'</pdfaSchema:property>'."\n";
$xmp .= "\t\t\t\t\t".'</rdf:li>'."\n";
$xmp .= "\t\t\t\t\t".'<rdf:li rdf:parseType="Resource">'."\n";
$xmp .= "\t\t\t\t\t\t".'<pdfaSchema:namespaceURI>http://ns.adobe.com/xap/1.0/mm/</pdfaSchema:namespaceURI>'."\n";
Expand Down Expand Up @@ -12281,7 +12281,7 @@ public function setDestination($name, $y=-1, $page='', $x=-1) {
$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;
Expand Down Expand Up @@ -12384,7 +12384,8 @@ public function Bookmark($txt, $level=0, $y=-1, $page='', $style='', $color=arra
$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;
Expand Down Expand Up @@ -23408,7 +23409,7 @@ protected function setSVGStyles($svgstyle, $prevsvgstyle, $x=0, $y=0, $w=1, $h=1
*/
protected function SVGPath($d, $style='') {
if ($this->state != 2) {
return;
return;
}
// set fill/stroke style
$op = TCPDF_STATIC::getPathPaintOperator($style, '');
Expand All @@ -23428,6 +23429,8 @@ protected function SVGPath($d, $style='') {
$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
Expand Down Expand Up @@ -23472,6 +23475,8 @@ protected function SVGPath($d, $style='') {
if ($ck == 1) {
$this->_outPoint($x, $y);
$firstcmd = false;
$xinitial = $x;
$yinitial = $y;
} else {
$this->_outLine($x, $y);
}
Expand Down Expand Up @@ -23659,8 +23664,8 @@ protected function SVGPath($d, $style='') {
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
Expand Down Expand Up @@ -23747,6 +23752,8 @@ protected function SVGPath($d, $style='') {
}
case 'Z': {
$this->_out('h');
$x = $x0 = $xinitial;
$y = $y0 = $yinitial;
break;
}
}
Expand Down

0 comments on commit b559600

Please sign in to comment.