From 8773ec952bf8fca025a38a48f6afa1aac64f7b1f Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Wed, 28 Aug 2024 12:38:04 +0100 Subject: [PATCH 1/5] Add class placeholders --- VERSION | 2 +- src/Base.php | 2 +- src/CSS.php | 36 ++++++++++++++++++++++++++++++++++++ src/ClassObjects.php | 1 + src/HTML.php | 36 ++++++++++++++++++++++++++++++++++++ src/JavaScript.php | 38 ++++++++++++++++++++++++++++++++++++++ src/MetaInfo.php | 4 +++- src/SVG.php | 36 ++++++++++++++++++++++++++++++++++++ 8 files changed, 152 insertions(+), 3 deletions(-) create mode 100644 src/CSS.php create mode 100644 src/HTML.php create mode 100644 src/JavaScript.php create mode 100644 src/SVG.php diff --git a/VERSION b/VERSION index c3325d2..9872fc6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.0.77 +8.0.78 diff --git a/src/Base.php b/src/Base.php index 5bb356a..670ad95 100644 --- a/src/Base.php +++ b/src/Base.php @@ -156,7 +156,7 @@ abstract class Base /** * TCPDF version. */ - protected string $version = '8.0.77'; + protected string $version = '8.0.78'; /** * Time is seconds since EPOCH when the document was created. diff --git a/src/CSS.php b/src/CSS.php new file mode 100644 index 0000000..bcefefa --- /dev/null +++ b/src/CSS.php @@ -0,0 +1,36 @@ + + * @copyright 2002-2024 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf + * + * This file is part of tc-lib-pdf software library. + */ + +namespace Com\Tecnick\Pdf; + +use Com\Tecnick\Pdf\Exception as PdfException; + +/** + * Com\Tecnick\Pdf\CSS + * + * CSS PDF class + * + * @since 2002-08-03 + * @category Library + * @package Pdf + * @author Nicola Asuni + * @copyright 2002-2024 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf + */ +abstract class CSS extends \Com\Tecnick\Pdf\SVG +{ +} diff --git a/src/ClassObjects.php b/src/ClassObjects.php index 6ad26c9..8835a2a 100644 --- a/src/ClassObjects.php +++ b/src/ClassObjects.php @@ -40,6 +40,7 @@ * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * @link https://github.com/tecnickcom/tc-lib-pdf * + * @SuppressWarnings(PHPMD.DepthOfInheritance) */ abstract class ClassObjects extends \Com\Tecnick\Pdf\Output { diff --git a/src/HTML.php b/src/HTML.php new file mode 100644 index 0000000..3c2e7f8 --- /dev/null +++ b/src/HTML.php @@ -0,0 +1,36 @@ + + * @copyright 2002-2024 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf + * + * This file is part of tc-lib-pdf software library. + */ + +namespace Com\Tecnick\Pdf; + +use Com\Tecnick\Pdf\Exception as PdfException; + +/** + * Com\Tecnick\Pdf\HTML + * + * HTML PDF class + * + * @since 2002-08-03 + * @category Library + * @package Pdf + * @author Nicola Asuni + * @copyright 2002-2024 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf + */ +abstract class HTML extends \Com\Tecnick\Pdf\CSS +{ +} diff --git a/src/JavaScript.php b/src/JavaScript.php new file mode 100644 index 0000000..a593592 --- /dev/null +++ b/src/JavaScript.php @@ -0,0 +1,38 @@ + + * @copyright 2002-2024 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf + * + * This file is part of tc-lib-pdf software library. + */ + +namespace Com\Tecnick\Pdf; + +use Com\Tecnick\Pdf\Exception as PdfException; + +/** + * Com\Tecnick\Pdf\JavaScript + * + * JavaScript PDF class + * + * @since 2002-08-03 + * @category Library + * @package Pdf + * @author Nicola Asuni + * @copyright 2002-2024 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf + * + * @SuppressWarnings(PHPMD.DepthOfInheritance) + */ +abstract class JavaScript extends \Com\Tecnick\Pdf\HTML +{ +} diff --git a/src/MetaInfo.php b/src/MetaInfo.php index 314c23f..25339b8 100644 --- a/src/MetaInfo.php +++ b/src/MetaInfo.php @@ -32,8 +32,10 @@ * @link https://github.com/tecnickcom/tc-lib-pdf * * @phpstan-import-type TViewerPref from Base + * + * @SuppressWarnings(PHPMD.DepthOfInheritance) */ -abstract class MetaInfo extends \Com\Tecnick\Pdf\Text +abstract class MetaInfo extends \Com\Tecnick\Pdf\JavaScript { /** * Valid document zoom modes diff --git a/src/SVG.php b/src/SVG.php new file mode 100644 index 0000000..d36e74d --- /dev/null +++ b/src/SVG.php @@ -0,0 +1,36 @@ + + * @copyright 2002-2024 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf + * + * This file is part of tc-lib-pdf software library. + */ + +namespace Com\Tecnick\Pdf; + +use Com\Tecnick\Pdf\Exception as PdfException; + +/** + * Com\Tecnick\Pdf\SVG + * + * SVG PDF class + * + * @since 2002-08-03 + * @category Library + * @package Pdf + * @author Nicola Asuni + * @copyright 2002-2024 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf + */ +abstract class SVG extends \Com\Tecnick\Pdf\Text +{ +} From 6448c7f66d30023689965446d9cfcec1312244ff Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Wed, 28 Aug 2024 14:39:42 +0100 Subject: [PATCH 2/5] Add units conversion function --- src/Base.php | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/src/Base.php b/src/Base.php index 670ad95..7056712 100644 --- a/src/Base.php +++ b/src/Base.php @@ -16,6 +16,7 @@ namespace Com\Tecnick\Pdf; +use Com\Tecnick\Pdf\Exception as PdfException; use Com\Tecnick\Barcode\Barcode as ObjBarcode; use Com\Tecnick\Color\Pdf as ObjColor; use Com\Tecnick\File\Cache as ObjCache; @@ -87,6 +88,21 @@ * 'borderpos': float, * } * + * + * @phpstan-type TRefUnitValues array{ + * 'parent': float, + * 'font': array{ + * 'rootsize': float, + * 'size': float, + * 'xheight': float, + * 'zerowidth': float, + * }, + * 'viewport': array{ + * 'width': float, + * 'height': float, + * }, + * } + * * @phpstan-type TStackBBox array * * @phpstan-import-type TAnnot from Output @@ -238,11 +254,33 @@ abstract class Base */ protected string $unit = 'mm'; + /** + * Valid HTML/CSS/SVG units. + * + * @var array + */ + protected const VALIDUNITS = [ + '%', 'ch', 'cm', 'em', 'ex', + 'in', 'mm', 'pc', 'pt', 'px', + 'rem', 'vh', 'vmax', 'vmin', 'vw', + ]; + + /** + * DPI (Dot Per Inch) Document Resolution (do not change). + * 1pt = 1/72 of 1in. + */ + protected float $dpi = 72.0; + /** * Unit of measure conversion ratio. */ protected float $kunit = 1.0; + /** + * Ratio between an internal point and pixel size. + */ + protected float $pointtopixelratio = 1.0; + /** * Version of the PDF/A mode or 0 otherwise. */ @@ -596,4 +634,96 @@ public function enableDefaultPageContent(bool $enable = true): void { $this->defPageContentEnabled = $enable; } + + /** + * Set the pixel/point ratio used to convert pixel values to points. + * + * @param float $val + * + * @return void + */ + public function setPointToPixelRatio(float $val): void + { + $this->pointtopixelratio = $val; + } + + /** + * Converts a string containing value and unit of measure to internal points. + * This is used to convert values for SVG, CSS, HTML. + * + * @param string|float|int $val String containing values and unit. + * @param TRefUnitValues $ref Reference values in points. + * @param string $defunit Default unit (can be one of the VALIDUNITS). + * + * @return float Internal points value. + */ + public function getUnitValuePoints( + string|float|int $val, + array $ref = [ + 'parent' => 1.0, + 'font' => [ + 'rootsize' => 10.0, + 'size' => 10.0, + 'xheight' => 5.0, + 'zerowidth' => 3.0, + ], + 'viewport' => [ + 'width' => 1000.0, + 'height' => 1000.0, + ], + ], + string $defunit = 'px', + ): float { + $unit = 'px'; + if (in_array($defunit, self::VALIDUNITS)) { + $unit = $defunit; + } + + $value = 0.0; + if (is_numeric($val)) { + $value = floatval($val); + } elseif (preg_match('/([0-9\.\-\+]+)([a-z%]{0,4})/', $val, $match)) { + $value = floatval($match[1]); + if (in_array($match[2], self::VALIDUNITS)) { + $unit = $match[2]; + } + } else { + throw new PdfException('Invalid value: ' . $val); + } + + return match ($unit) { + // Percentage relative to the parent element. + '%' => (($value * $ref['parent']) / 100), + // Relative to the width of the "0" (zero) + 'ch' => ($value * $ref['font']['zerowidth']), + // Centimeters. + 'cm' => (($value * $this->dpi) / 2.54), + // Relative to the font-size of the element. + 'em' => ($value * $ref['font']['size']), + // Relative to the x-height of the current font. + 'ex' => ($value * $ref['font']['xheight']), + // Inches. + 'in' => ($value * $this->dpi), + // Millimeters. + 'mm' => (($value * $this->dpi) / 25.4), + // One pica is 12 points. + 'pc' => ($value * 12), + // Points. + 'pt' => $value, + // Pixels. + 'px' => ($value * $this->pointtopixelratio), + // Relative to font-size of the root element. + 'rem' => ($value * $ref['font']['rootsize']), + // Relative to 1% of the height of the viewport. + 'vh' => (($value * $ref['viewport']['height']) / 100), + // Relative to 1% of viewport's* larger dimension. + 'vmax' => (($value * max($ref['viewport']['height'], $ref['viewport']['width'])) / 100), + // Relative to 1% of viewport's smaller dimension. + 'vmin' => (($value * min($ref['viewport']['height'], $ref['viewport']['width'])) / 100), + // Relative to 1% of the width of the viewport. + 'vw' => (($value * $ref['viewport']['width']) / 100), + // Default to pixels. + default => ($value * $this->pointtopixelratio), + }; + } } From c077ae565cab152fca06a3dcae16bb1cea28397e Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Thu, 29 Aug 2024 09:44:00 +0100 Subject: [PATCH 3/5] Update tc-lib-pdf-graph --- composer.json | 2 +- resources/debian/control | 2 +- resources/rpm/rpm.spec | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 0038237..a6b016c 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "tecnickcom/tc-lib-unicode-data": "^2.0", "tecnickcom/tc-lib-unicode": "^2.0", "tecnickcom/tc-lib-pdf-page": "^4.2", - "tecnickcom/tc-lib-pdf-graph": "^2.1" + "tecnickcom/tc-lib-pdf-graph": "^2.2" }, "require-dev": { "pdepend/pdepend": "2.13.0", diff --git a/resources/debian/control b/resources/debian/control index 2328ff2..a8bc8b5 100644 --- a/resources/debian/control +++ b/resources/debian/control @@ -10,6 +10,6 @@ Vcs-Git: https://github.com/~#VENDOR#~/~#PROJECT#~.git Package: ~#PKGNAME#~ Provides: php-~#PROJECT#~ Architecture: all -Depends: php (>= 8.0.0), php-date, php-tecnickcom-tc-lib-barcode (<< 3.0.0), php-tecnickcom-tc-lib-barcode (>= 2.2.3), php-tecnickcom-tc-lib-color (<< 3.0.0), php-tecnickcom-tc-lib-color (>= 2.2.2), php-tecnickcom-tc-lib-pdf-image (<< 3.0.0), php-tecnickcom-tc-lib-pdf-image (>= 2.1.1), php-tecnickcom-tc-lib-pdf-font (<< 3.0.0), php-tecnickcom-tc-lib-pdf-font (>= 2.5.0), php-tecnickcom-tc-lib-file (<< 3.0.0), php-tecnickcom-tc-lib-file (>= 2.0.13), php-tecnickcom-tc-lib-pdf-encrypt (<< 3.0.0), php-tecnickcom-tc-lib-pdf-encrypt (>= 2.1.4), php-tecnickcom-tc-lib-unicode-data (<< 3.0.0), php-tecnickcom-tc-lib-unicode-data (>= 2.0.13), php-tecnickcom-tc-lib-unicode (<< 3.0.0), php-tecnickcom-tc-lib-unicode (>= 2.0.13), php-tecnickcom-tc-lib-pdf-page (<< 5.0.0), php-tecnickcom-tc-lib-pdf-page (>= 4.2.0), php-tecnickcom-tc-lib-pdf-graph (<< 3.0.0), php-tecnickcom-tc-lib-pdf-graph (>= 2.1.1), ${misc:Depends} +Depends: php (>= 8.0.0), php-date, php-tecnickcom-tc-lib-barcode (<< 3.0.0), php-tecnickcom-tc-lib-barcode (>= 2.2.3), php-tecnickcom-tc-lib-color (<< 3.0.0), php-tecnickcom-tc-lib-color (>= 2.2.2), php-tecnickcom-tc-lib-pdf-image (<< 3.0.0), php-tecnickcom-tc-lib-pdf-image (>= 2.1.1), php-tecnickcom-tc-lib-pdf-font (<< 3.0.0), php-tecnickcom-tc-lib-pdf-font (>= 2.5.0), php-tecnickcom-tc-lib-file (<< 3.0.0), php-tecnickcom-tc-lib-file (>= 2.0.13), php-tecnickcom-tc-lib-pdf-encrypt (<< 3.0.0), php-tecnickcom-tc-lib-pdf-encrypt (>= 2.1.4), php-tecnickcom-tc-lib-unicode-data (<< 3.0.0), php-tecnickcom-tc-lib-unicode-data (>= 2.0.13), php-tecnickcom-tc-lib-unicode (<< 3.0.0), php-tecnickcom-tc-lib-unicode (>= 2.0.13), php-tecnickcom-tc-lib-pdf-page (<< 5.0.0), php-tecnickcom-tc-lib-pdf-page (>= 4.2.0), php-tecnickcom-tc-lib-pdf-graph (<< 3.0.0), php-tecnickcom-tc-lib-pdf-graph (>= 2.2.0), ${misc:Depends} Description: PHP Barcode library This library includes PHP classes to generate PDF documents. diff --git a/resources/rpm/rpm.spec b/resources/rpm/rpm.spec index be6f31a..3175b9e 100644 --- a/resources/rpm/rpm.spec +++ b/resources/rpm/rpm.spec @@ -38,7 +38,7 @@ Requires: php-composer(%{c_vendor}/tc-lib-unicode) >= 2.0.13 Requires: php-composer(%{c_vendor}/tc-lib-pdf-page) < 5.0.0 Requires: php-composer(%{c_vendor}/tc-lib-pdf-page) >= 4.2.0 Requires: php-composer(%{c_vendor}/tc-lib-pdf-graph) < 3.0.0 -Requires: php-composer(%{c_vendor}/tc-lib-pdf-graph) >= 2.1.1 +Requires: php-composer(%{c_vendor}/tc-lib-pdf-graph) >= 2.2.0 Provides: php-composer(%{c_vendor}/%{gh_project}) = %{version} Provides: php-%{gh_project} = %{version} From a6b60f9ec5e883e141e43721c0cfca8d78bd0ab9 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Thu, 29 Aug 2024 09:44:14 +0100 Subject: [PATCH 4/5] SVG tranforamtion --- src/SVG.php | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/src/SVG.php b/src/SVG.php index d36e74d..136c5ec 100644 --- a/src/SVG.php +++ b/src/SVG.php @@ -30,7 +30,121 @@ * @copyright 2002-2024 Nicola Asuni - Tecnick.com LTD * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * @link https://github.com/tecnickcom/tc-lib-pdf + * + * @phpstan-import-type TTMatrix from \Com\Tecnick\Pdf\Graph\Base */ abstract class SVG extends \Com\Tecnick\Pdf\Text { + /** + * Get the tranformation matrix from the SVG 'transform' attribute. + * + * @param string $attr Transformation attribute. + * + * @return TTMatrix Transformation matrix. + */ + protected function getSVGTransformMatrix(string $attr): array + { + $transform = []; + $tma = $this->graph::IDMATRIX; + + if ( + !preg_match_all( + '/(matrix|translate|scale|rotate|skewX|skewY)[\s]*\(([^\)]+)\)/si', + $attr, + $transform, + PREG_SET_ORDER, + ) > 0 + ) { + return $tma; + } + + foreach ($transform as $data) { + if (empty($data[2])) { + continue; + } + + $tmb = $this->graph::IDMATRIX; + $val = $data[2]; + $regs = []; + + switch ($data[1]) { + case 'matrix': + if ( + preg_match( + '/([a-z0-9\-\.]+)[\,\s]+' + . '([a-z0-9\-\.]+)[\,\s]+' + . '([a-z0-9\-\.]+)[\,\s]+' + . '([a-z0-9\-\.]+)[\,\s]+' + . '([a-z0-9\-\.]+)[\,\s]+' + . '([a-z0-9\-\.]+)/si', + $val, + $regs, + ) + ) { + $tmb[0] = floatval($regs[1]); + $tmb[1] = floatval($regs[2]); + $tmb[2] = floatval($regs[3]); + $tmb[3] = floatval($regs[4]); + $tmb[4] = floatval($regs[5]); + $tmb[5] = floatval($regs[6]); + } + break; + case 'translate': + if (preg_match('/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $val, $regs)) { + $tmb[4] = floatval($regs[1]); + $tmb[5] = floatval($regs[2]); + break; + } + if (preg_match('/([a-z0-9\-\.]+)/si', $val, $regs)) { + $tmb[4] = floatval($regs[1]); + } + break; + case 'scale': + if (preg_match('/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $val, $regs)) { + $tmb[0] = floatval($regs[1]); + $tmb[3] = floatval($regs[2]); + break; + } + if (preg_match('/([a-z0-9\-\.]+)/si', $val, $regs)) { + $tmb[0] = floatval($regs[1]); + $tmb[3] = $tmb[0]; + } + break; + case 'rotate': + if (preg_match('/([0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $val, $regs)) { + $ang = deg2rad(floatval($regs[1])); + $trx = floatval($regs[2]); + $try = floatval($regs[3]); + $tmb[0] = cos($ang); + $tmb[1] = sin($ang); + $tmb[2] = -$tmb[1]; + $tmb[3] = $tmb[0]; + $tmb[4] = ($trx * (1 - $tmb[0])) - ($try * $tmb[2]); + $tmb[5] = ($try * (1 - $tmb[3])) - ($trx * $tmb[1]); + break; + } + if (preg_match('/([0-9\-\.]+)/si', $val, $regs)) { + $ang = deg2rad(floatval($regs[1])); + $tmb[0] = cos($ang); + $tmb[1] = sin($ang); + $tmb = [$tmb[0], $tmb[1], -$tmb[1], $tmb[0], 0, 0]; + } + break; + case 'skewX': + if (preg_match('/([0-9\-\.]+)/si', $val, $regs)) { + $tmb[2] = tan(deg2rad(floatval($regs[1]))); + } + break; + case 'skewY': + if (preg_match('/([0-9\-\.]+)/si', $val, $regs)) { + $tmb[1] = tan(deg2rad(floatval($regs[1]))); + } + break; + } + + $tma = $this->graph->getCtmProduct($tma, $tmb); + } + + return $tma; + } } From fed6d94f30926424963f6aa579138de1137516f1 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Fri, 30 Aug 2024 08:01:04 +0100 Subject: [PATCH 5/5] Update tc-lib-pdf-encrypt and encode /DA. --- VERSION | 2 +- resources/debian/control | 2 +- resources/rpm/rpm.spec | 2 +- src/Base.php | 2 +- src/Output.php | 11 ++++++----- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index 9872fc6..f65a3a8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.0.78 +8.0.79 diff --git a/resources/debian/control b/resources/debian/control index a8bc8b5..eb54e55 100644 --- a/resources/debian/control +++ b/resources/debian/control @@ -10,6 +10,6 @@ Vcs-Git: https://github.com/~#VENDOR#~/~#PROJECT#~.git Package: ~#PKGNAME#~ Provides: php-~#PROJECT#~ Architecture: all -Depends: php (>= 8.0.0), php-date, php-tecnickcom-tc-lib-barcode (<< 3.0.0), php-tecnickcom-tc-lib-barcode (>= 2.2.3), php-tecnickcom-tc-lib-color (<< 3.0.0), php-tecnickcom-tc-lib-color (>= 2.2.2), php-tecnickcom-tc-lib-pdf-image (<< 3.0.0), php-tecnickcom-tc-lib-pdf-image (>= 2.1.1), php-tecnickcom-tc-lib-pdf-font (<< 3.0.0), php-tecnickcom-tc-lib-pdf-font (>= 2.5.0), php-tecnickcom-tc-lib-file (<< 3.0.0), php-tecnickcom-tc-lib-file (>= 2.0.13), php-tecnickcom-tc-lib-pdf-encrypt (<< 3.0.0), php-tecnickcom-tc-lib-pdf-encrypt (>= 2.1.4), php-tecnickcom-tc-lib-unicode-data (<< 3.0.0), php-tecnickcom-tc-lib-unicode-data (>= 2.0.13), php-tecnickcom-tc-lib-unicode (<< 3.0.0), php-tecnickcom-tc-lib-unicode (>= 2.0.13), php-tecnickcom-tc-lib-pdf-page (<< 5.0.0), php-tecnickcom-tc-lib-pdf-page (>= 4.2.0), php-tecnickcom-tc-lib-pdf-graph (<< 3.0.0), php-tecnickcom-tc-lib-pdf-graph (>= 2.2.0), ${misc:Depends} +Depends: php (>= 8.0.0), php-date, php-tecnickcom-tc-lib-barcode (<< 3.0.0), php-tecnickcom-tc-lib-barcode (>= 2.2.3), php-tecnickcom-tc-lib-color (<< 3.0.0), php-tecnickcom-tc-lib-color (>= 2.2.2), php-tecnickcom-tc-lib-pdf-image (<< 3.0.0), php-tecnickcom-tc-lib-pdf-image (>= 2.1.1), php-tecnickcom-tc-lib-pdf-font (<< 3.0.0), php-tecnickcom-tc-lib-pdf-font (>= 2.5.0), php-tecnickcom-tc-lib-file (<< 3.0.0), php-tecnickcom-tc-lib-file (>= 2.0.13), php-tecnickcom-tc-lib-pdf-encrypt (<< 3.0.0), php-tecnickcom-tc-lib-pdf-encrypt (>= 2.1.5), php-tecnickcom-tc-lib-unicode-data (<< 3.0.0), php-tecnickcom-tc-lib-unicode-data (>= 2.0.13), php-tecnickcom-tc-lib-unicode (<< 3.0.0), php-tecnickcom-tc-lib-unicode (>= 2.0.13), php-tecnickcom-tc-lib-pdf-page (<< 5.0.0), php-tecnickcom-tc-lib-pdf-page (>= 4.2.0), php-tecnickcom-tc-lib-pdf-graph (<< 3.0.0), php-tecnickcom-tc-lib-pdf-graph (>= 2.2.0), ${misc:Depends} Description: PHP Barcode library This library includes PHP classes to generate PDF documents. diff --git a/resources/rpm/rpm.spec b/resources/rpm/rpm.spec index 3175b9e..74f04cf 100644 --- a/resources/rpm/rpm.spec +++ b/resources/rpm/rpm.spec @@ -30,7 +30,7 @@ Requires: php-composer(%{c_vendor}/tc-lib-pdf-font) >= 2.5.0 Requires: php-composer(%{c_vendor}/tc-lib-file) < 3.0.0 Requires: php-composer(%{c_vendor}/tc-lib-file) >= 2.0.13 Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) < 3.0.0 -Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) >= 2.1.4 +Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) >= 2.1.5 Requires: php-composer(%{c_vendor}/tc-lib-unicode-data) < 3.0.0 Requires: php-composer(%{c_vendor}/tc-lib-unicode-data) >= 2.0.13 Requires: php-composer(%{c_vendor}/tc-lib-unicode) < 3.0.0 diff --git a/src/Base.php b/src/Base.php index 7056712..f20cc68 100644 --- a/src/Base.php +++ b/src/Base.php @@ -172,7 +172,7 @@ abstract class Base /** * TCPDF version. */ - protected string $version = '8.0.78'; + protected string $version = '8.0.79'; /** * Time is seconds since EPOCH when the document was created. diff --git a/src/Output.php b/src/Output.php index 186a067..3125e3d 100644 --- a/src/Output.php +++ b/src/Output.php @@ -901,7 +901,7 @@ protected function getOutCatalog(): string } $font = $this->font->getFont('helvetica'); - $out .= ' /DA (/F' . $font['i'] . ' 0 Tf 0 g)'; + $out .= ' /DA ' . $this->encrypt->escapeDataString('/F' . $font['i'] . ' 0 Tf 0 g', $oid); $out .= ' /Q ' . (($this->rtl) ? '2' : '0'); //$out .= ' /XFA '; $out .= ' >>'; @@ -1657,7 +1657,7 @@ protected function getOutAnnotationOptSubtype(array $annot, int $pagenum, int $o 'caret' => $this->getOutAnnotationOptSubtypeCaret($annot), 'circle' => $this->getOutAnnotationOptSubtypeCircle($annot), 'fileattachment' => $this->getOutAnnotationOptSubtypeFileattachment($annot, $key), - 'freetext' => $this->getOutAnnotationOptSubtypeFreetext($annot), + 'freetext' => $this->getOutAnnotationOptSubtypeFreetext($annot, $oid), 'highlight' => $this->getOutAnnotationOptSubtypeHighlight($annot), 'ink' => $this->getOutAnnotationOptSubtypeInk($annot), 'line' => $this->getOutAnnotationOptSubtypeLine($annot), @@ -1827,12 +1827,13 @@ protected function getOutAnnotationOptSubtypeLink( * Returns the output code associated with the annotation opt.subtype.freetext. * * @param TAnnot $annot Array containing page annotations. + * @param int $oid Annotation Object ID. */ - protected function getOutAnnotationOptSubtypeFreetext(array $annot): string + protected function getOutAnnotationOptSubtypeFreetext(array $annot, int $oid): string { $out = ''; if (! empty($annot['opt']['da'])) { - $out .= ' /DA (' . $annot['opt']['da'] . ')'; + $out .= ' /DA ' . $this->encrypt->escapeDataString($annot['opt']['da'], $oid); } if ( @@ -2304,7 +2305,7 @@ protected function getOutAnnotationOptSubtypeWidget( } if (! empty($annot['opt']['da'])) { - $out .= ' /DA (' . $annot['opt']['da'] . ')'; + $out .= ' /DA ' . $this->encrypt->escapeDataString($annot['opt']['da'], $oid); } if (