diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bb8c28d..f29016c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,7 +6,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] + php: ['5.6', '7.0', '7.1', '7.2', '7.3'] steps: - name: Checkout uses: actions/checkout@v2 @@ -26,12 +26,12 @@ jobs: run: | ./vendor/bin/phpunit - testsPhp8: - name: Run PHP Unit tests (>= 8.0) + testsPhp74and8: + name: Run PHP Unit tests (>= 7.4) runs-on: ubuntu-20.04 strategy: matrix: - php: ['8.0', '8.1', '8.2'] + php: ['7.4', '8.0', '8.1', '8.2'] steps: - name: Checkout uses: actions/checkout@v2 diff --git a/LICENSE.txt b/LICENSE.txt index 45672fa..f1778c7 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2020 Setasign GmbH & Co. KG, https://www.setasign.com +Copyright (c) 2023 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 diff --git a/src/FpdfTpl.php b/src/FpdfTpl.php index 4b93f53..0f3a6fc 100644 --- a/src/FpdfTpl.php +++ b/src/FpdfTpl.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/FpdfTplTrait.php b/src/FpdfTplTrait.php index 96d2362..2da9d55 100644 --- a/src/FpdfTplTrait.php +++ b/src/FpdfTplTrait.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ @@ -13,7 +13,7 @@ /** * Trait FpdfTplTrait * - * This class adds a templating feature to FPDF and tFPDF. + * This trait adds a templating feature to FPDF and tFPDF. */ trait FpdfTplTrait { diff --git a/src/Fpdi.php b/src/Fpdi.php index d577987..78ffeef 100644 --- a/src/Fpdi.php +++ b/src/Fpdi.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/FpdiException.php b/src/FpdiException.php index 2286667..0414d8b 100644 --- a/src/FpdiException.php +++ b/src/FpdiException.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/FpdiTrait.php b/src/FpdiTrait.php index d43cf3b..4ca9808 100644 --- a/src/FpdiTrait.php +++ b/src/FpdiTrait.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ @@ -124,9 +124,10 @@ protected function setMinPdfVersion($pdfVersion) * Get a new pdf parser instance. * * @param StreamReader $streamReader + * @param array $parserParams Individual parameters passed to the parser instance. * @return PdfParser|FpdiPdfParser */ - protected function getPdfParserInstance(StreamReader $streamReader) + protected function getPdfParserInstance(StreamReader $streamReader, array $parserParams = []) { // note: if you get an exception here - turn off errors/warnings on not found for your autoloader. // psr-4 (https://www.php-fig.org/psr/psr-4/) says: Autoloader implementations MUST NOT throw @@ -134,7 +135,7 @@ protected function getPdfParserInstance(StreamReader $streamReader) /** @noinspection PhpUndefinedClassInspection */ if (\class_exists(FpdiPdfParser::class)) { /** @noinspection PhpUndefinedClassInspection */ - return new FpdiPdfParser($streamReader); + return new FpdiPdfParser($streamReader, $parserParams); } return new PdfParser($streamReader); @@ -145,9 +146,10 @@ protected function getPdfParserInstance(StreamReader $streamReader) * * @param string|resource|PdfReader|StreamReader $file An open file descriptor, a path to a file, a PdfReader * instance or a StreamReader instance. + * @param array $parserParams Individual parameters passed to the parser instance. * @return string */ - protected function getPdfReaderId($file) + protected function getPdfReaderId($file, array $parserParams = []) { if (\is_resource($file)) { $id = (string) $file; @@ -178,7 +180,7 @@ protected function getPdfReaderId($file) $streamReader = $file; } - $reader = new PdfReader($this->getPdfParserInstance($streamReader)); + $reader = new PdfReader($this->getPdfParserInstance($streamReader, $parserParams)); /** @noinspection OffsetOperationsInspection */ $this->readers[$id] = $reader; @@ -211,7 +213,24 @@ protected function getPdfReader($id) */ public function setSourceFile($file) { - $this->currentReaderId = $this->getPdfReaderId($file); + return $this->setSourceFileWithParserParams($file); + } + + /** + * Set the source PDF file with parameters which are passed to the parser instance. + * + * This method allows us to pass e.g. authentication information to the parser instance. + * + * @param string|resource|StreamReader $file Path to the file or a stream resource or a StreamReader instance. + * @param array $parserParams Individual parameters passed to the parser instance. + * @return int The page count of the PDF document. + * @throws CrossReferenceException + * @throws PdfParserException + * @throws PdfTypeException + */ + public function setSourceFileWithParserParams($file, array $parserParams = []) + { + $this->currentReaderId = $this->getPdfReaderId($file, $parserParams); $this->objectsToCopy[$this->currentReaderId] = []; $reader = $this->getPdfReader($this->currentReaderId); diff --git a/src/PdfParser/CrossReference/AbstractReader.php b/src/PdfParser/CrossReference/AbstractReader.php index b54237b..bcf21d6 100644 --- a/src/PdfParser/CrossReference/AbstractReader.php +++ b/src/PdfParser/CrossReference/AbstractReader.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/CrossReference/CrossReference.php b/src/PdfParser/CrossReference/CrossReference.php index c47e8c4..c9d19b9 100644 --- a/src/PdfParser/CrossReference/CrossReference.php +++ b/src/PdfParser/CrossReference/CrossReference.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/CrossReference/CrossReferenceException.php b/src/PdfParser/CrossReference/CrossReferenceException.php index 7d88d5d..8a1a589 100644 --- a/src/PdfParser/CrossReference/CrossReferenceException.php +++ b/src/PdfParser/CrossReference/CrossReferenceException.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/CrossReference/FixedReader.php b/src/PdfParser/CrossReference/FixedReader.php index ed417df..8abf7fb 100644 --- a/src/PdfParser/CrossReference/FixedReader.php +++ b/src/PdfParser/CrossReference/FixedReader.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/CrossReference/LineReader.php b/src/PdfParser/CrossReference/LineReader.php index 5b67744..bcbd8e4 100644 --- a/src/PdfParser/CrossReference/LineReader.php +++ b/src/PdfParser/CrossReference/LineReader.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/CrossReference/ReaderInterface.php b/src/PdfParser/CrossReference/ReaderInterface.php index d2dfdd0..0bdc0ab 100644 --- a/src/PdfParser/CrossReference/ReaderInterface.php +++ b/src/PdfParser/CrossReference/ReaderInterface.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Filter/Ascii85.php b/src/PdfParser/Filter/Ascii85.php index 1dc936d..1a1882d 100644 --- a/src/PdfParser/Filter/Ascii85.php +++ b/src/PdfParser/Filter/Ascii85.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Filter/Ascii85Exception.php b/src/PdfParser/Filter/Ascii85Exception.php index f4b6758..83a780c 100644 --- a/src/PdfParser/Filter/Ascii85Exception.php +++ b/src/PdfParser/Filter/Ascii85Exception.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Filter/AsciiHex.php b/src/PdfParser/Filter/AsciiHex.php index d0c3436..c3ba800 100644 --- a/src/PdfParser/Filter/AsciiHex.php +++ b/src/PdfParser/Filter/AsciiHex.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Filter/FilterException.php b/src/PdfParser/Filter/FilterException.php index c55a7a8..c71ff38 100644 --- a/src/PdfParser/Filter/FilterException.php +++ b/src/PdfParser/Filter/FilterException.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Filter/FilterInterface.php b/src/PdfParser/Filter/FilterInterface.php index 3700190..3aa4872 100644 --- a/src/PdfParser/Filter/FilterInterface.php +++ b/src/PdfParser/Filter/FilterInterface.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Filter/Flate.php b/src/PdfParser/Filter/Flate.php index 48ad768..1cefa15 100644 --- a/src/PdfParser/Filter/Flate.php +++ b/src/PdfParser/Filter/Flate.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Filter/FlateException.php b/src/PdfParser/Filter/FlateException.php index d897ac8..7791ca7 100644 --- a/src/PdfParser/Filter/FlateException.php +++ b/src/PdfParser/Filter/FlateException.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Filter/Lzw.php b/src/PdfParser/Filter/Lzw.php index 0d6cf38..f0b16c8 100644 --- a/src/PdfParser/Filter/Lzw.php +++ b/src/PdfParser/Filter/Lzw.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Filter/LzwException.php b/src/PdfParser/Filter/LzwException.php index 6ebad4f..9f42038 100644 --- a/src/PdfParser/Filter/LzwException.php +++ b/src/PdfParser/Filter/LzwException.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/PdfParser.php b/src/PdfParser/PdfParser.php index f724314..a127cfc 100644 --- a/src/PdfParser/PdfParser.php +++ b/src/PdfParser/PdfParser.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ @@ -145,7 +145,7 @@ protected function resolveFileHeader() } /** - * Get the cross reference instance. + * Get the cross-reference instance. * * @return CrossReference * @throws CrossReferenceException diff --git a/src/PdfParser/PdfParserException.php b/src/PdfParser/PdfParserException.php index 6d034d8..0629d9d 100644 --- a/src/PdfParser/PdfParserException.php +++ b/src/PdfParser/PdfParserException.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/StreamReader.php b/src/PdfParser/StreamReader.php index ee40ebb..0c484fa 100644 --- a/src/PdfParser/StreamReader.php +++ b/src/PdfParser/StreamReader.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Tokenizer.php b/src/PdfParser/Tokenizer.php index a3bcd01..5c1ccd8 100644 --- a/src/PdfParser/Tokenizer.php +++ b/src/PdfParser/Tokenizer.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Type/PdfArray.php b/src/PdfParser/Type/PdfArray.php index 5d0bbbd..33c6bc4 100644 --- a/src/PdfParser/Type/PdfArray.php +++ b/src/PdfParser/Type/PdfArray.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Type/PdfBoolean.php b/src/PdfParser/Type/PdfBoolean.php index ba4233a..ad7c5d6 100644 --- a/src/PdfParser/Type/PdfBoolean.php +++ b/src/PdfParser/Type/PdfBoolean.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Type/PdfDictionary.php b/src/PdfParser/Type/PdfDictionary.php index 2818842..8991322 100644 --- a/src/PdfParser/Type/PdfDictionary.php +++ b/src/PdfParser/Type/PdfDictionary.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Type/PdfHexString.php b/src/PdfParser/Type/PdfHexString.php index 0084ada..86694b0 100644 --- a/src/PdfParser/Type/PdfHexString.php +++ b/src/PdfParser/Type/PdfHexString.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Type/PdfIndirectObject.php b/src/PdfParser/Type/PdfIndirectObject.php index 15786d0..8b7898f 100644 --- a/src/PdfParser/Type/PdfIndirectObject.php +++ b/src/PdfParser/Type/PdfIndirectObject.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Type/PdfIndirectObjectReference.php b/src/PdfParser/Type/PdfIndirectObjectReference.php index 2725d0c..975e9e8 100644 --- a/src/PdfParser/Type/PdfIndirectObjectReference.php +++ b/src/PdfParser/Type/PdfIndirectObjectReference.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Type/PdfName.php b/src/PdfParser/Type/PdfName.php index 194a13f..0fbfe52 100644 --- a/src/PdfParser/Type/PdfName.php +++ b/src/PdfParser/Type/PdfName.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Type/PdfNull.php b/src/PdfParser/Type/PdfNull.php index 0c4c108..4830564 100644 --- a/src/PdfParser/Type/PdfNull.php +++ b/src/PdfParser/Type/PdfNull.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Type/PdfNumeric.php b/src/PdfParser/Type/PdfNumeric.php index 9de912b..454b368 100644 --- a/src/PdfParser/Type/PdfNumeric.php +++ b/src/PdfParser/Type/PdfNumeric.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Type/PdfStream.php b/src/PdfParser/Type/PdfStream.php index 7adf218..f72114e 100644 --- a/src/PdfParser/Type/PdfStream.php +++ b/src/PdfParser/Type/PdfStream.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Type/PdfString.php b/src/PdfParser/Type/PdfString.php index 1636e68..41b66ed 100644 --- a/src/PdfParser/Type/PdfString.php +++ b/src/PdfParser/Type/PdfString.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Type/PdfToken.php b/src/PdfParser/Type/PdfToken.php index 012b9fd..8293c28 100644 --- a/src/PdfParser/Type/PdfToken.php +++ b/src/PdfParser/Type/PdfToken.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Type/PdfType.php b/src/PdfParser/Type/PdfType.php index 7672dcd..065ad38 100644 --- a/src/PdfParser/Type/PdfType.php +++ b/src/PdfParser/Type/PdfType.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfParser/Type/PdfTypeException.php b/src/PdfParser/Type/PdfTypeException.php index 593d147..88d2c20 100644 --- a/src/PdfParser/Type/PdfTypeException.php +++ b/src/PdfParser/Type/PdfTypeException.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfReader/DataStructure/Rectangle.php b/src/PdfReader/DataStructure/Rectangle.php index b76e687..afbe569 100644 --- a/src/PdfReader/DataStructure/Rectangle.php +++ b/src/PdfReader/DataStructure/Rectangle.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfReader/Page.php b/src/PdfReader/Page.php index 663a7d7..8d08c95 100644 --- a/src/PdfReader/Page.php +++ b/src/PdfReader/Page.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfReader/PageBoundaries.php b/src/PdfReader/PageBoundaries.php index 9a6a1f3..ec24cde 100644 --- a/src/PdfReader/PageBoundaries.php +++ b/src/PdfReader/PageBoundaries.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfReader/PdfReader.php b/src/PdfReader/PdfReader.php index e31b110..6e4dae8 100644 --- a/src/PdfReader/PdfReader.php +++ b/src/PdfReader/PdfReader.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/PdfReader/PdfReaderException.php b/src/PdfReader/PdfReaderException.php index 99f7d12..2b3487e 100644 --- a/src/PdfReader/PdfReaderException.php +++ b/src/PdfReader/PdfReaderException.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/TcpdfFpdi.php b/src/TcpdfFpdi.php index 9e6825b..8f3c095 100644 --- a/src/TcpdfFpdi.php +++ b/src/TcpdfFpdi.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/Tfpdf/FpdfTpl.php b/src/Tfpdf/FpdfTpl.php index c00d53d..7b02bc8 100644 --- a/src/Tfpdf/FpdfTpl.php +++ b/src/Tfpdf/FpdfTpl.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/Tfpdf/Fpdi.php b/src/Tfpdf/Fpdi.php index 88a564f..c350889 100644 --- a/src/Tfpdf/Fpdi.php +++ b/src/Tfpdf/Fpdi.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/src/autoload.php b/src/autoload.php index 4c3df9d..7ea6b05 100644 --- a/src/autoload.php +++ b/src/autoload.php @@ -4,7 +4,7 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com) + * @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License */ diff --git a/tests/unit/FpdiTraitTest.php b/tests/unit/FpdiTraitTest.php index 6d9eb08..3d77bba 100644 --- a/tests/unit/FpdiTraitTest.php +++ b/tests/unit/FpdiTraitTest.php @@ -3,7 +3,10 @@ namespace setasign\Fpdi\unit; use PHPUnit\Framework\TestCase; +use setasign\Fpdi\Fpdi; use setasign\Fpdi\FpdiTrait; +use setasign\Fpdi\PdfParser\PdfParser; +use setasign\Fpdi\PdfParser\StreamReader; abstract class FpdiTraitTest extends TestCase { @@ -26,4 +29,30 @@ public function testUseImportedPageWithoutSettingSourceFile() $this->expectException(\InvalidArgumentException::class); $fpdi->useImportedPage(1); } + + /** + * Test if $parserParams is forwarded to getPdfParserInstance() method. + */ + public function testSetSourceFileWithParserParams() + { + $parserParams = ['any' => 'thing']; + + $pdf = $this->getMockBuilder(get_class($this->getInstance())) + ->setMethods(['getPdfParserInstance', 'setMinPdfVersion']) + ->getMock(); + + $fh = fopen(__DIR__ . '/../_files/pdfs/Example-PDF-2.pdf', 'rb+'); + $streamReader = new StreamReader($fh); + + $pdf->expects($this->once()) + ->method('getPdfParserInstance') + ->with($streamReader, $parserParams) + ->willReturn(new PdfParser($streamReader)); + + $pdf->expects($this->once()) + ->method('setMinPdfVersion'); + + $pageCount = $pdf->setSourceFileWithParserParams($streamReader, $parserParams); + $this->assertSame(10, $pageCount); + } }