diff --git a/mod/assign/feedback/editpdf/classes/pdf.php b/mod/assign/feedback/editpdf/classes/pdf.php index b8273f5c92c..134cfaecc43 100644 --- a/mod/assign/feedback/editpdf/classes/pdf.php +++ b/mod/assign/feedback/editpdf/classes/pdf.php @@ -23,13 +23,14 @@ */ namespace assignfeedback_editpdf; -use setasign\Fpdi\TcpdfFpdi; + +use setasign\Fpdi\Tcpdf\Fpdi; defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->libdir.'/pdflib.php'); -require_once($CFG->dirroot.'/mod/assign/feedback/editpdf/fpdi/autoload.php'); +require_once($CFG->dirroot.'/mod/assign/feedback/editpdf/fpdi/src/autoload.php'); /** * Library code for manipulating PDFs @@ -38,7 +39,7 @@ require_once($CFG->dirroot.'/mod/assign/feedback/editpdf/fpdi/autoload.php'); * @copyright 2012 Davo Smith * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class pdf extends TcpdfFpdi { +class pdf extends Fpdi { /** @var int the number of the current page in the PDF being processed */ protected $currentpage = 0; diff --git a/mod/assign/feedback/editpdf/fpdi/LICENSE.txt b/mod/assign/feedback/editpdf/fpdi/LICENSE.txt new file mode 100644 index 00000000000..84e590c1164 --- /dev/null +++ b/mod/assign/feedback/editpdf/fpdi/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2024 Setasign GmbH & Co. KG, https://www.setasign.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/mod/assign/feedback/editpdf/fpdi/README.md b/mod/assign/feedback/editpdf/fpdi/README.md new file mode 100644 index 00000000000..18998fb5751 --- /dev/null +++ b/mod/assign/feedback/editpdf/fpdi/README.md @@ -0,0 +1,130 @@ +FPDI - Free PDF Document Importer +================================= + +[![Latest Stable Version](https://poser.pugx.org/setasign/fpdi/v/stable.svg)](https://packagist.org/packages/setasign/fpdi) +[![Total Downloads](https://poser.pugx.org/setasign/fpdi/downloads.svg)](https://packagist.org/packages/setasign/fpdi) +[![License](https://poser.pugx.org/setasign/fpdi/license.svg)](https://packagist.org/packages/setasign/fpdi) + +:heavy_exclamation_mark: This document refers to FPDI 2. Version 1 is deprecated and development is discontinued. :heavy_exclamation_mark: + +FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF +documents and use them as templates in [FPDF](http://www.fpdf.org), which was developed by Olivier Plathey. Apart +from a copy of [FPDF](http://www.fpdf.org), FPDI does not require any special PHP extensions. + +FPDI can also be used as an extension for [TCPDF](https://github.com/tecnickcom/TCPDF) or +[tFPDF](http://fpdf.org/en/script/script92.php), too. + +## Installation with [Composer](https://packagist.org/packages/setasign/fpdi) + +Because FPDI can be used with FPDF, TCPDF or tFPDF we haven't added a fixed dependency in the main +composer.json file. You need to add the dependency to the PDF generation library of your choice +yourself. + +To use FPDI with FPDF include following in your composer.json file: + +```json +{ + "require": { + "setasign/fpdf": "1.8.*", + "setasign/fpdi": "^2.5" + } +} +``` + +If you want to use TCPDF, you have to update your composer.json to: + +```json +{ + "require": { + "tecnickcom/tcpdf": "6.6.*", + "setasign/fpdi": "^2.5" + } +} +``` + +If you want to use tFPDF, you have to update your composer.json to: + +```json +{ + "require": { + "setasign/tfpdf": "1.33.*", + "setasign/fpdi": "^2.3" + } +} +``` + +## Manual Installation + +If you do not use composer, just require the autoload.php in the /src folder: + +```php +require_once('src/autoload.php'); +``` + +If you have a PSR-4 autoloader implemented, just register the src path as follows: +```php +$loader = new \Example\Psr4AutoloaderClass; +$loader->register(); +$loader->addNamespace('setasign\Fpdi', 'path/to/src/'); +``` + +## Changes to Version 1 + +Version 2 is a complete rewrite from scratch of FPDI which comes with: +- Namespaced code +- Clean and up-to-date code base and style +- PSR-4 compatible autoloading +- Performance improvements by up to 100% +- Less memory consumption +- Native support for reading PDFs from strings or stream-resources +- Support for documents with "invalid" data before their file-header +- Optimized page tree resolving +- Usage of individual exceptions +- Several test types (unit, functional and visual tests) + +We tried to keep the main methods and logical workflow the same as in version 1 but please +notice that there were incompatible changes which you should consider when updating to +version 2: +- You need to load the code using the `src/autoload.php` file instead of `classes/FPDI.php`. +- The classes and traits are namespaced now: `setasign\Fpdi` +- Page boundaries beginning with a slash, such as `/MediaBox`, are not supported anymore. Remove + the slash or use a constant of `PdfReader\PageBoundaries`. +- The parameters $x, $y, $width and $height of the `useTemplate()` or `getTemplateSize()` + method have more logical correct default values now. Passing `0` as width or height will + result in an `InvalidArgumentException` now. +- The return value of `getTemplateSize()` had changed to an array with more speaking keys + and reusability: Use `width` instead of `w` and `height` instead of `h`. +- If you want to use **FPDI with TCPDF** you need to refactor your code to use the class `Tcpdf\Fpdi` +(since 2.1; before it was `TcpdfFpdi`) instead of `FPDI`. + +## Example and Documentation + +A simple example, that imports a single page and places this onto a new created page: + +```php +AddPage(); +// set the source file +$pdf->setSourceFile("Fantastic-Speaker.pdf"); +// import page 1 +$tplId = $pdf->importPage(1); +// use the imported page and place it at point 10,10 with a width of 100 mm +$pdf->useTemplate($tplId, 10, 10, 100); + +$pdf->Output(); +``` + +A full end-user documentation and API reference is available [here](https://manuals.setasign.com/fpdi-manual/). diff --git a/mod/assign/feedback/editpdf/fpdi/SECURITY.md b/mod/assign/feedback/editpdf/fpdi/SECURITY.md new file mode 100644 index 00000000000..da9c516dd74 --- /dev/null +++ b/mod/assign/feedback/editpdf/fpdi/SECURITY.md @@ -0,0 +1,5 @@ +## Security contact information + +To report a security vulnerability, please use the +[Tidelift security contact](https://tidelift.com/security). +Tidelift will coordinate the fix and disclosure. diff --git a/mod/assign/feedback/editpdf/fpdi/composer.json b/mod/assign/feedback/editpdf/fpdi/composer.json new file mode 100644 index 00000000000..44347e36487 --- /dev/null +++ b/mod/assign/feedback/editpdf/fpdi/composer.json @@ -0,0 +1,51 @@ +{ + "name": "setasign/fpdi", + "homepage": "https://www.setasign.com/fpdi", + "description": "FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Because it is also possible to use FPDI with TCPDF, there are no fixed dependencies defined. Please see suggestions for packages which evaluates the dependencies automatically.", + "type": "library", + "keywords": [ + "pdf", + "fpdi", + "fpdf" + ], + "license": "MIT", + "autoload": { + "psr-4": { + "setasign\\Fpdi\\": "src/" + } + }, + "require": { + "php": "^7.1 || ^8.0", + "ext-zlib": "*" + }, + "conflict": { + "setasign/tfpdf": "<1.31" + }, + "authors": [ + { + "name": "Jan Slabon", + "email": "jan.slabon@setasign.com", + "homepage": "https://www.setasign.com" + }, + { + "name": "Maximilian Kresse", + "email": "maximilian.kresse@setasign.com", + "homepage": "https://www.setasign.com" + } + ], + "suggest": { + "setasign/fpdf": "FPDI will extend this class but as it is also possible to use TCPDF or tFPDF as an alternative. There's no fixed dependency configured." + }, + "require-dev": { + "phpunit/phpunit": "^7", + "setasign/fpdf": "~1.8.6", + "tecnickcom/tcpdf": "^6.2", + "setasign/tfpdf": "~1.33", + "squizlabs/php_codesniffer": "^3.5" + }, + "autoload-dev": { + "psr-4": { + "setasign\\Fpdi\\": "tests/" + } + } +} diff --git a/mod/assign/feedback/editpdf/fpdi/readme_moodle.txt b/mod/assign/feedback/editpdf/fpdi/readme_moodle.txt index 3ce4699e1a5..e2c2205abc9 100644 --- a/mod/assign/feedback/editpdf/fpdi/readme_moodle.txt +++ b/mod/assign/feedback/editpdf/fpdi/readme_moodle.txt @@ -16,4 +16,4 @@ Installation ------------ 1) Download the latest version of fpdi from the url above. 2) Unzip the src directory files into this directory. -3) Update mod/assign/feedback/editpdf/fpdi/Tcpdf/Fpdi.php(or whichever file it has been replaced with) to extend 'pdf' instead of 'TCPDF'. +3) Update mod/assign/feedback/editpdf/fpdi/src/Tcpdf/Fpdi.php(or whichever file it has been replaced with) to extend 'pdf' instead of 'TCPDF'. diff --git a/mod/assign/feedback/editpdf/fpdi/FpdfTpl.php b/mod/assign/feedback/editpdf/fpdi/src/FpdfTpl.php similarity index 83% rename from mod/assign/feedback/editpdf/fpdi/FpdfTpl.php rename to mod/assign/feedback/editpdf/fpdi/src/FpdfTpl.php index 0f3a6fc7cc8..e6a15e7dcd9 100644 --- a/mod/assign/feedback/editpdf/fpdi/FpdfTpl.php +++ b/mod/assign/feedback/editpdf/fpdi/src/FpdfTpl.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/FpdfTplTrait.php b/mod/assign/feedback/editpdf/fpdi/src/FpdfTplTrait.php similarity index 98% rename from mod/assign/feedback/editpdf/fpdi/FpdfTplTrait.php rename to mod/assign/feedback/editpdf/fpdi/src/FpdfTplTrait.php index 2da9d55f3ca..aae257126bc 100644 --- a/mod/assign/feedback/editpdf/fpdi/FpdfTplTrait.php +++ b/mod/assign/feedback/editpdf/fpdi/src/FpdfTplTrait.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ @@ -109,7 +109,7 @@ trait FpdfTplTrait unset($x['tpl']); \extract($x, EXTR_IF_EXISTS); /** @noinspection NotOptimalIfConditionsInspection */ - /** @noinspection PhpConditionAlreadyCheckedInspection */ + /** @phpstan-ignore function.alreadyNarrowedType */ if (\is_array($x)) { $x = 0; } @@ -253,9 +253,9 @@ trait FpdfTplTrait $this->currentTemplateId = $templateId; $this->h = $height; - $this->hPt = $height / $this->k; + $this->hPt = $height * $this->k; $this->w = $width; - $this->wPt = $width / $this->k; + $this->wPt = $width * $this->k; $this->SetXY($this->lMargin, $this->tMargin); $this->SetRightMargin($this->w - $width + $this->rMargin); diff --git a/mod/assign/feedback/editpdf/fpdi/FpdfTrait.php b/mod/assign/feedback/editpdf/fpdi/src/FpdfTrait.php similarity index 96% rename from mod/assign/feedback/editpdf/fpdi/FpdfTrait.php rename to mod/assign/feedback/editpdf/fpdi/src/FpdfTrait.php index 67fa561c456..e48ee9d9cec 100644 --- a/mod/assign/feedback/editpdf/fpdi/FpdfTrait.php +++ b/mod/assign/feedback/editpdf/fpdi/src/FpdfTrait.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ @@ -140,8 +140,8 @@ trait FpdfTrait $rect = sprintf('%.2F %.2F %.2F %.2F', $pl[0], $pl[1], $pl[0] + $pl[2], $pl[1] - $pl[3]); $this->_put('<_put('/A <_textstring($pl[4]) . '>>'); if (isset($pl['importedLink'])) { + $this->_put('/A <_escape($pl[4]) . ')>>'); $values = $pl['importedLink']['pdfObject']->value; foreach ($values as $name => $entry) { @@ -158,6 +158,7 @@ trait FpdfTrait $this->_put($s); } } else { + $this->_put('/A <_textstring($pl[4]) . '>>'); $this->_put('/Border [0 0 0]', false); } $this->_put('>>'); diff --git a/mod/assign/feedback/editpdf/fpdi/Fpdi.php b/mod/assign/feedback/editpdf/fpdi/src/Fpdi.php similarity index 87% rename from mod/assign/feedback/editpdf/fpdi/Fpdi.php rename to mod/assign/feedback/editpdf/fpdi/src/Fpdi.php index fd158a6e683..de030d9f75b 100644 --- a/mod/assign/feedback/editpdf/fpdi/Fpdi.php +++ b/mod/assign/feedback/editpdf/fpdi/src/Fpdi.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ @@ -30,5 +30,5 @@ class Fpdi extends FpdfTpl * * @string */ - const VERSION = '2.6.0'; + const VERSION = '2.6.3'; } diff --git a/mod/assign/feedback/editpdf/fpdi/FpdiException.php b/mod/assign/feedback/editpdf/fpdi/src/FpdiException.php similarity index 81% rename from mod/assign/feedback/editpdf/fpdi/FpdiException.php rename to mod/assign/feedback/editpdf/fpdi/src/FpdiException.php index 0414d8bfac1..a178c41206f 100644 --- a/mod/assign/feedback/editpdf/fpdi/FpdiException.php +++ b/mod/assign/feedback/editpdf/fpdi/src/FpdiException.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/FpdiTrait.php b/mod/assign/feedback/editpdf/fpdi/src/FpdiTrait.php similarity index 99% rename from mod/assign/feedback/editpdf/fpdi/FpdiTrait.php rename to mod/assign/feedback/editpdf/fpdi/src/FpdiTrait.php index 6d57b995d24..a15cafee64f 100644 --- a/mod/assign/feedback/editpdf/fpdi/FpdiTrait.php +++ b/mod/assign/feedback/editpdf/fpdi/src/FpdiTrait.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ @@ -444,6 +444,7 @@ trait FpdiTrait unset($x['pageId']); \extract($x, EXTR_IF_EXISTS); /** @noinspection NotOptimalIfConditionsInspection */ + /** @phpstan-ignore function.alreadyNarrowedType */ if (\is_array($x)) { $x = 0; } diff --git a/mod/assign/feedback/editpdf/fpdi/GraphicsState.php b/mod/assign/feedback/editpdf/fpdi/src/GraphicsState.php similarity index 94% rename from mod/assign/feedback/editpdf/fpdi/GraphicsState.php rename to mod/assign/feedback/editpdf/fpdi/src/GraphicsState.php index 27feafba765..4464181957d 100644 --- a/mod/assign/feedback/editpdf/fpdi/GraphicsState.php +++ b/mod/assign/feedback/editpdf/fpdi/src/GraphicsState.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ @@ -26,7 +26,7 @@ class GraphicsState /** * @param Matrix|null $ctm */ - public function __construct(Matrix $ctm = null) + public function __construct(?Matrix $ctm = null) { if ($ctm === null) { $ctm = new Matrix(); diff --git a/mod/assign/feedback/editpdf/fpdi/Math/Matrix.php b/mod/assign/feedback/editpdf/fpdi/src/Math/Matrix.php similarity index 96% rename from mod/assign/feedback/editpdf/fpdi/Math/Matrix.php rename to mod/assign/feedback/editpdf/fpdi/src/Math/Matrix.php index 662a5a2b36a..578bdc8847f 100644 --- a/mod/assign/feedback/editpdf/fpdi/Math/Matrix.php +++ b/mod/assign/feedback/editpdf/fpdi/src/Math/Matrix.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/Math/Vector.php b/mod/assign/feedback/editpdf/fpdi/src/Math/Vector.php similarity index 94% rename from mod/assign/feedback/editpdf/fpdi/Math/Vector.php rename to mod/assign/feedback/editpdf/fpdi/src/Math/Vector.php index df782d487b0..fe203482927 100644 --- a/mod/assign/feedback/editpdf/fpdi/Math/Vector.php +++ b/mod/assign/feedback/editpdf/fpdi/src/Math/Vector.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/CrossReference/AbstractReader.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/CrossReference/AbstractReader.php similarity index 97% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/CrossReference/AbstractReader.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/CrossReference/AbstractReader.php index bcf21d68c4b..8953e6370a2 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/CrossReference/AbstractReader.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/CrossReference/AbstractReader.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/CrossReference/CrossReference.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/CrossReference/CrossReference.php similarity index 99% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/CrossReference/CrossReference.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/CrossReference/CrossReference.php index 7fa146d188c..1cbe0e2163d 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/CrossReference/CrossReference.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/CrossReference/CrossReference.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/CrossReference/CrossReferenceException.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/CrossReference/CrossReferenceException.php similarity index 94% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/CrossReference/CrossReferenceException.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/CrossReference/CrossReferenceException.php index 8a1a589e8f2..412b375e48a 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/CrossReference/CrossReferenceException.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/CrossReference/CrossReferenceException.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/CrossReference/FixedReader.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/CrossReference/FixedReader.php similarity index 98% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/CrossReference/FixedReader.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/CrossReference/FixedReader.php index 8abf7fbc8a8..603bde3182e 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/CrossReference/FixedReader.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/CrossReference/FixedReader.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/CrossReference/LineReader.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/CrossReference/LineReader.php similarity index 98% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/CrossReference/LineReader.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/CrossReference/LineReader.php index bcbd8e46649..c921fe74639 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/CrossReference/LineReader.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/CrossReference/LineReader.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/CrossReference/ReaderInterface.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/CrossReference/ReaderInterface.php similarity index 91% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/CrossReference/ReaderInterface.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/CrossReference/ReaderInterface.php index 0bdc0ab062d..a98fb135294 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/CrossReference/ReaderInterface.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/CrossReference/ReaderInterface.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/Ascii85.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/Ascii85.php similarity index 97% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/Ascii85.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/Ascii85.php index 1a1882dc6d7..f3efd4c8065 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/Ascii85.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/Ascii85.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/Ascii85Exception.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/Ascii85Exception.php similarity index 87% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/Ascii85Exception.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/Ascii85Exception.php index 83a780c87e7..e37eaa7d9dd 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/Ascii85Exception.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/Ascii85Exception.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/AsciiHex.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/AsciiHex.php similarity index 94% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/AsciiHex.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/AsciiHex.php index c3ba800337d..1eb4a792fdd 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/AsciiHex.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/AsciiHex.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/FilterException.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/FilterException.php similarity index 86% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/FilterException.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/FilterException.php index c71ff382d14..18a07ce0003 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/FilterException.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/FilterException.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/FilterInterface.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/FilterInterface.php similarity index 86% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/FilterInterface.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/FilterInterface.php index 3aa487202d3..93d7996d256 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/FilterInterface.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/FilterInterface.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/Flate.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/Flate.php similarity index 97% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/Flate.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/Flate.php index 29f07998c31..83bc0e2492b 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/Flate.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/Flate.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/FlateException.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/FlateException.php similarity index 87% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/FlateException.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/FlateException.php index 7791ca70714..aa3a2b3977d 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/FlateException.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/FlateException.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/Lzw.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/Lzw.php similarity index 98% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/Lzw.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/Lzw.php index f0b16c843fc..54c3b78c3e1 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/Lzw.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/Lzw.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/LzwException.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/LzwException.php similarity index 85% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/LzwException.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/LzwException.php index 9f42038e5a3..297edacd43b 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Filter/LzwException.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Filter/LzwException.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/PdfParser.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/PdfParser.php similarity index 86% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/PdfParser.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/PdfParser.php index 22a72e63940..02af9ca7ace 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/PdfParser.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/PdfParser.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ @@ -281,33 +281,34 @@ class PdfParser default: if (\is_numeric($token)) { - if (($token2 = $this->tokenizer->getNextToken()) !== false) { - if (\is_numeric($token2) && ($token3 = $this->tokenizer->getNextToken()) !== false) { - switch ($token3) { - case 'obj': - if ($expectedType !== null && $expectedType !== PdfIndirectObject::class) { - throw new Type\PdfTypeException( - 'Got unexpected token type.', - Type\PdfTypeException::INVALID_DATA_TYPE - ); - } + $token2 = $this->tokenizer->getNextToken(); + if ($token2 !== false) { + if (\is_numeric($token2)) { + $token3 = $this->tokenizer->getNextToken(); + if ($token3 === 'obj') { + if ($expectedType !== null && $expectedType !== PdfIndirectObject::class) { + throw new Type\PdfTypeException( + 'Got unexpected token type.', + Type\PdfTypeException::INVALID_DATA_TYPE + ); + } - return $this->parsePdfIndirectObject((int)$token, (int)$token2); - case 'R': - if ( - $expectedType !== null && - $expectedType !== PdfIndirectObjectReference::class - ) { - throw new Type\PdfTypeException( - 'Got unexpected token type.', - Type\PdfTypeException::INVALID_DATA_TYPE - ); - } + return $this->parsePdfIndirectObject((int) $token, (int) $token2); + } elseif ($token3 === 'R') { + if ( + $expectedType !== null && + $expectedType !== PdfIndirectObjectReference::class + ) { + throw new Type\PdfTypeException( + 'Got unexpected token type.', + Type\PdfTypeException::INVALID_DATA_TYPE + ); + } - return PdfIndirectObjectReference::create((int)$token, (int)$token2); + return PdfIndirectObjectReference::create((int) $token, (int) $token2); + } elseif ($token3 !== false) { + $this->tokenizer->pushStack($token3); } - - $this->tokenizer->pushStack($token3); } $this->tokenizer->pushStack($token2); diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/PdfParserException.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/PdfParserException.php similarity index 92% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/PdfParserException.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/PdfParserException.php index 0629d9d8a3e..b2264ab342b 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/PdfParserException.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/PdfParserException.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/StreamReader.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/StreamReader.php similarity index 97% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/StreamReader.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/StreamReader.php index a493a85507b..3018418e922 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/StreamReader.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/StreamReader.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ @@ -418,16 +418,20 @@ class StreamReader \fseek($this->stream, $pos); $this->position = $pos; - $this->buffer = $length > 0 ? \fread($this->stream, $length) : ''; - $this->bufferLength = \strlen($this->buffer); $this->offset = 0; + if ($length > 0) { + $this->buffer = (string) \fread($this->stream, $length); + } else { + $this->buffer = ''; + } + $this->bufferLength = \strlen($this->buffer); // If a stream wrapper is in use it is possible that // length values > 8096 will be ignored, so use the // increaseLength()-method to correct that behavior if ($this->bufferLength < $length && $this->increaseLength($length - $this->bufferLength)) { // increaseLength parameter is $minLength, so cut to have only the required bytes in the buffer - $this->buffer = \substr($this->buffer, 0, $length); + $this->buffer = (string) \substr($this->buffer, 0, $length); $this->bufferLength = \strlen($this->buffer); } } diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Tokenizer.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Tokenizer.php similarity index 92% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Tokenizer.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Tokenizer.php index 5c1ccd897e1..889d036c611 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Tokenizer.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Tokenizer.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ @@ -68,7 +68,7 @@ class Tokenizer /** * Get next token. * - * @return bool|string + * @return false|string */ public function getNextToken() { @@ -117,11 +117,8 @@ class Tokenizer } while ( // Break the loop if a delimiter or white space char is matched // in the current buffer or increase the buffers length - $lastBuffer !== false && - ( - $bufferOffset + $pos === \strlen($lastBuffer) && - $this->streamReader->increaseLength() - ) + $bufferOffset + $pos === \strlen($lastBuffer) + && $this->streamReader->increaseLength() ); $result = \substr($lastBuffer, $bufferOffset - 1, $pos + 1); diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfArray.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfArray.php similarity index 96% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfArray.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfArray.php index c7981b63a28..15f55497730 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfArray.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfArray.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfBoolean.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfBoolean.php similarity index 92% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfBoolean.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfBoolean.php index ad7c5d60005..3007a65f8e7 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfBoolean.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfBoolean.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfDictionary.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfDictionary.php similarity index 89% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfDictionary.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfDictionary.php index 8991322c77d..db4009caf5f 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfDictionary.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfDictionary.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ @@ -48,14 +48,13 @@ class PdfDictionary extends PdfType if (!($key instanceof PdfName)) { $lastToken = null; // ignore all other entries and search for the closing brackets - while (($token = $tokenizer->getNextToken()) !== '>' && $token !== false && $lastToken !== '>') { + while (($token = $tokenizer->getNextToken()) !== '>' || $lastToken !== '>') { + if ($token === false) { + return false; + } $lastToken = $token; } - if ($token === false) { - return false; - } - break; } @@ -107,7 +106,7 @@ class PdfDictionary extends PdfType * @return PdfNull|PdfType * @throws PdfTypeException */ - public static function get($dictionary, $key, PdfType $default = null) + public static function get($dictionary, $key, ?PdfType $default = null) { $dictionary = self::ensure($dictionary); @@ -115,9 +114,7 @@ class PdfDictionary extends PdfType return $dictionary->value[$key]; } - return $default === null - ? new PdfNull() - : $default; + return $default ?? new PdfNull(); } /** diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfHexString.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfHexString.php similarity index 96% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfHexString.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfHexString.php index cd9d2b6cf4b..309706b34af 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfHexString.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfHexString.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfIndirectObject.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfIndirectObject.php similarity index 97% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfIndirectObject.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfIndirectObject.php index 72a80e19dbb..ce51d48d552 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfIndirectObject.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfIndirectObject.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfIndirectObjectReference.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfIndirectObjectReference.php similarity index 94% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfIndirectObjectReference.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfIndirectObjectReference.php index 975e9e8ea8d..1ace37843eb 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfIndirectObjectReference.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfIndirectObjectReference.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfName.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfName.php similarity index 96% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfName.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfName.php index 0fbfe525735..3732aecc0ed 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfName.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfName.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfNull.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfNull.php similarity index 82% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfNull.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfNull.php index 483056492bd..7aef36330b6 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfNull.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfNull.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfNumeric.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfNumeric.php similarity index 93% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfNumeric.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfNumeric.php index 454b36864c1..dd8b3ddae40 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfNumeric.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfNumeric.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfStream.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfStream.php similarity index 98% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfStream.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfStream.php index cfa2cdbfd79..0a4036874d3 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfStream.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfStream.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ @@ -31,11 +31,11 @@ class PdfStream extends PdfType * * @param PdfDictionary $dictionary * @param StreamReader $reader - * @param PdfParser $parser Optional to keep backwards compatibility + * @param PdfParser|null $parser Optional to keep backwards compatibility * @return self * @throws PdfTypeException */ - public static function parse(PdfDictionary $dictionary, StreamReader $reader, PdfParser $parser = null) + public static function parse(PdfDictionary $dictionary, StreamReader $reader, ?PdfParser $parser = null) { $v = new self(); $v->value = $dictionary; diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfString.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfString.php similarity index 98% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfString.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfString.php index dc4ce3359e8..89b90c5d9e4 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfString.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfString.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfToken.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfToken.php similarity index 92% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfToken.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfToken.php index 8293c28a17d..a0de203e8fd 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfToken.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfToken.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfType.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfType.php similarity index 97% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfType.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfType.php index ecd18b3b094..5330a44c76b 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfType.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfType.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfTypeException.php b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfTypeException.php similarity index 87% rename from mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfTypeException.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfTypeException.php index 88d2c2059b0..3d2b93cdda1 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfParser/Type/PdfTypeException.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfParser/Type/PdfTypeException.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfReader/DataStructure/Rectangle.php b/mod/assign/feedback/editpdf/fpdi/src/PdfReader/DataStructure/Rectangle.php similarity index 98% rename from mod/assign/feedback/editpdf/fpdi/PdfReader/DataStructure/Rectangle.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfReader/DataStructure/Rectangle.php index afbe569bad6..9f5cd745d4b 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfReader/DataStructure/Rectangle.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfReader/DataStructure/Rectangle.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfReader/Page.php b/mod/assign/feedback/editpdf/fpdi/src/PdfReader/Page.php similarity index 98% rename from mod/assign/feedback/editpdf/fpdi/PdfReader/Page.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfReader/Page.php index ad3c0c26375..c2463dd2880 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfReader/Page.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfReader/Page.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ @@ -281,6 +281,8 @@ class Page * All coordinates are normalized in view to rotation and translation of the boundary-box, so that their * origin is lower-left. * + * The URI is the binary value of the PDF string object. It can be in PdfDocEncoding or in UTF-16BE encoding. + * * @return array */ public function getExternalLinks($box = PageBoundaries::CROP_BOX) diff --git a/mod/assign/feedback/editpdf/fpdi/PdfReader/PageBoundaries.php b/mod/assign/feedback/editpdf/fpdi/src/PdfReader/PageBoundaries.php similarity index 97% rename from mod/assign/feedback/editpdf/fpdi/PdfReader/PageBoundaries.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfReader/PageBoundaries.php index ec24cdea500..351542185fe 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfReader/PageBoundaries.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfReader/PageBoundaries.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/PdfReader/PdfReader.php b/mod/assign/feedback/editpdf/fpdi/src/PdfReader/PdfReader.php similarity index 95% rename from mod/assign/feedback/editpdf/fpdi/PdfReader/PdfReader.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfReader/PdfReader.php index 6e4dae8c77c..f3effe353ab 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfReader/PdfReader.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfReader/PdfReader.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ @@ -109,7 +109,7 @@ class PdfReader /** * Get a page instance. * - * @param int $pageNumber + * @param int|numeric-string $pageNumber * @return Page * @throws PdfTypeException * @throws CrossReferenceException @@ -219,7 +219,10 @@ class PdfReader $type = PdfDictionary::get($object->value, 'Type'); if ($type->value === 'Pages') { - $readPages(PdfDictionary::get($object->value, 'Kids'), PdfDictionary::get($object->value, 'Count')); + $readPages( + PdfType::resolve(PdfDictionary::get($object->value, 'Kids'), $this->parser), + PdfType::resolve(PdfDictionary::get($object->value, 'Count'), $this->parser) + ); } else { $this->pages[] = $object; } diff --git a/mod/assign/feedback/editpdf/fpdi/PdfReader/PdfReaderException.php b/mod/assign/feedback/editpdf/fpdi/src/PdfReader/PdfReaderException.php similarity index 89% rename from mod/assign/feedback/editpdf/fpdi/PdfReader/PdfReaderException.php rename to mod/assign/feedback/editpdf/fpdi/src/PdfReader/PdfReaderException.php index 2b3487e95b1..ecebdb96194 100644 --- a/mod/assign/feedback/editpdf/fpdi/PdfReader/PdfReaderException.php +++ b/mod/assign/feedback/editpdf/fpdi/src/PdfReader/PdfReaderException.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/Tcpdf/Fpdi.php b/mod/assign/feedback/editpdf/fpdi/src/Tcpdf/Fpdi.php similarity index 99% rename from mod/assign/feedback/editpdf/fpdi/Tcpdf/Fpdi.php rename to mod/assign/feedback/editpdf/fpdi/src/Tcpdf/Fpdi.php index 05c8fe031f3..6fd17cc6b1c 100644 --- a/mod/assign/feedback/editpdf/fpdi/Tcpdf/Fpdi.php +++ b/mod/assign/feedback/editpdf/fpdi/src/Tcpdf/Fpdi.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ @@ -46,7 +46,7 @@ class Fpdi extends \pdf * * @string */ - const VERSION = '2.6.0'; + const VERSION = '2.6.3'; /** * A counter for template ids. diff --git a/mod/assign/feedback/editpdf/fpdi/TcpdfFpdi.php b/mod/assign/feedback/editpdf/fpdi/src/TcpdfFpdi.php similarity index 88% rename from mod/assign/feedback/editpdf/fpdi/TcpdfFpdi.php rename to mod/assign/feedback/editpdf/fpdi/src/TcpdfFpdi.php index 8f3c095e047..84f68196924 100644 --- a/mod/assign/feedback/editpdf/fpdi/TcpdfFpdi.php +++ b/mod/assign/feedback/editpdf/fpdi/src/TcpdfFpdi.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/Tfpdf/FpdfTpl.php b/mod/assign/feedback/editpdf/fpdi/src/Tfpdf/FpdfTpl.php similarity index 87% rename from mod/assign/feedback/editpdf/fpdi/Tfpdf/FpdfTpl.php rename to mod/assign/feedback/editpdf/fpdi/src/Tfpdf/FpdfTpl.php index 7b02bc85435..6cf8a6cd1ef 100644 --- a/mod/assign/feedback/editpdf/fpdi/Tfpdf/FpdfTpl.php +++ b/mod/assign/feedback/editpdf/fpdi/src/Tfpdf/FpdfTpl.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/fpdi/Tfpdf/Fpdi.php b/mod/assign/feedback/editpdf/fpdi/src/Tfpdf/Fpdi.php similarity index 84% rename from mod/assign/feedback/editpdf/fpdi/Tfpdf/Fpdi.php rename to mod/assign/feedback/editpdf/fpdi/src/Tfpdf/Fpdi.php index bcf4472310e..9df7c82e988 100644 --- a/mod/assign/feedback/editpdf/fpdi/Tfpdf/Fpdi.php +++ b/mod/assign/feedback/editpdf/fpdi/src/Tfpdf/Fpdi.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ @@ -28,5 +28,5 @@ class Fpdi extends FpdfTpl * * @string */ - const VERSION = '2.6.0'; + const VERSION = '2.6.3'; } diff --git a/mod/assign/feedback/editpdf/fpdi/autoload.php b/mod/assign/feedback/editpdf/fpdi/src/autoload.php similarity index 89% rename from mod/assign/feedback/editpdf/fpdi/autoload.php rename to mod/assign/feedback/editpdf/fpdi/src/autoload.php index 7ea6b0558bb..cace75bd1ae 100644 --- a/mod/assign/feedback/editpdf/fpdi/autoload.php +++ b/mod/assign/feedback/editpdf/fpdi/src/autoload.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2024 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/mod/assign/feedback/editpdf/thirdpartylibs.xml b/mod/assign/feedback/editpdf/thirdpartylibs.xml index 8fc2fc02de5..9ea7b8b69f3 100644 --- a/mod/assign/feedback/editpdf/thirdpartylibs.xml +++ b/mod/assign/feedback/editpdf/thirdpartylibs.xml @@ -4,7 +4,7 @@ fpdi FPDI Collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. - 2.6.0 + 2.6.3 MIT https://github.com/Setasign/FPDI