Skip to content

Commit 984c0a6

Browse files
authored
Merge pull request #175 from Setasign/development
Development
2 parents 8e02c37 + 8952a40 commit 984c0a6

50 files changed

Lines changed: 107 additions & 59 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
runs-on: ubuntu-20.04
77
strategy:
88
matrix:
9-
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
9+
php: ['5.6', '7.0', '7.1', '7.2', '7.3']
1010
steps:
1111
- name: Checkout
1212
uses: actions/checkout@v2
@@ -26,12 +26,12 @@ jobs:
2626
run: |
2727
./vendor/bin/phpunit
2828
29-
testsPhp8:
30-
name: Run PHP Unit tests (>= 8.0)
29+
testsPhp74and8:
30+
name: Run PHP Unit tests (>= 7.4)
3131
runs-on: ubuntu-20.04
3232
strategy:
3333
matrix:
34-
php: ['8.0', '8.1', '8.2']
34+
php: ['7.4', '8.0', '8.1', '8.2']
3535
steps:
3636
- name: Checkout
3737
uses: actions/checkout@v2

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2020 Setasign GmbH & Co. KG, https://www.setasign.com
3+
Copyright (c) 2023 Setasign GmbH & Co. KG, https://www.setasign.com
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

src/FpdfTpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This file is part of FPDI
55
*
66
* @package setasign\Fpdi
7-
* @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com)
7+
* @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com)
88
* @license http://opensource.org/licenses/mit-license The MIT License
99
*/
1010

src/FpdfTplTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This file is part of FPDI
55
*
66
* @package setasign\Fpdi
7-
* @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com)
7+
* @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com)
88
* @license http://opensource.org/licenses/mit-license The MIT License
99
*/
1010

@@ -13,7 +13,7 @@
1313
/**
1414
* Trait FpdfTplTrait
1515
*
16-
* This class adds a templating feature to FPDF and tFPDF.
16+
* This trait adds a templating feature to FPDF and tFPDF.
1717
*/
1818
trait FpdfTplTrait
1919
{

src/Fpdi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This file is part of FPDI
55
*
66
* @package setasign\Fpdi
7-
* @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com)
7+
* @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com)
88
* @license http://opensource.org/licenses/mit-license The MIT License
99
*/
1010

src/FpdiException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This file is part of FPDI
55
*
66
* @package setasign\Fpdi
7-
* @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com)
7+
* @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com)
88
* @license http://opensource.org/licenses/mit-license The MIT License
99
*/
1010

src/FpdiTrait.php

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This file is part of FPDI
55
*
66
* @package setasign\Fpdi
7-
* @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com)
7+
* @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com)
88
* @license http://opensource.org/licenses/mit-license The MIT License
99
*/
1010

@@ -124,17 +124,18 @@ protected function setMinPdfVersion($pdfVersion)
124124
* Get a new pdf parser instance.
125125
*
126126
* @param StreamReader $streamReader
127+
* @param array $parserParams Individual parameters passed to the parser instance.
127128
* @return PdfParser|FpdiPdfParser
128129
*/
129-
protected function getPdfParserInstance(StreamReader $streamReader)
130+
protected function getPdfParserInstance(StreamReader $streamReader, array $parserParams = [])
130131
{
131132
// note: if you get an exception here - turn off errors/warnings on not found for your autoloader.
132133
// psr-4 (https://www.php-fig.org/psr/psr-4/) says: Autoloader implementations MUST NOT throw
133134
// exceptions, MUST NOT raise errors of any level, and SHOULD NOT return a value.
134135
/** @noinspection PhpUndefinedClassInspection */
135136
if (\class_exists(FpdiPdfParser::class)) {
136137
/** @noinspection PhpUndefinedClassInspection */
137-
return new FpdiPdfParser($streamReader);
138+
return new FpdiPdfParser($streamReader, $parserParams);
138139
}
139140

140141
return new PdfParser($streamReader);
@@ -145,9 +146,10 @@ protected function getPdfParserInstance(StreamReader $streamReader)
145146
*
146147
* @param string|resource|PdfReader|StreamReader $file An open file descriptor, a path to a file, a PdfReader
147148
* instance or a StreamReader instance.
149+
* @param array $parserParams Individual parameters passed to the parser instance.
148150
* @return string
149151
*/
150-
protected function getPdfReaderId($file)
152+
protected function getPdfReaderId($file, array $parserParams = [])
151153
{
152154
if (\is_resource($file)) {
153155
$id = (string) $file;
@@ -178,7 +180,7 @@ protected function getPdfReaderId($file)
178180
$streamReader = $file;
179181
}
180182

181-
$reader = new PdfReader($this->getPdfParserInstance($streamReader));
183+
$reader = new PdfReader($this->getPdfParserInstance($streamReader, $parserParams));
182184
/** @noinspection OffsetOperationsInspection */
183185
$this->readers[$id] = $reader;
184186

@@ -211,7 +213,24 @@ protected function getPdfReader($id)
211213
*/
212214
public function setSourceFile($file)
213215
{
214-
$this->currentReaderId = $this->getPdfReaderId($file);
216+
return $this->setSourceFileWithParserParams($file);
217+
}
218+
219+
/**
220+
* Set the source PDF file with parameters which are passed to the parser instance.
221+
*
222+
* This method allows us to pass e.g. authentication information to the parser instance.
223+
*
224+
* @param string|resource|StreamReader $file Path to the file or a stream resource or a StreamReader instance.
225+
* @param array $parserParams Individual parameters passed to the parser instance.
226+
* @return int The page count of the PDF document.
227+
* @throws CrossReferenceException
228+
* @throws PdfParserException
229+
* @throws PdfTypeException
230+
*/
231+
public function setSourceFileWithParserParams($file, array $parserParams = [])
232+
{
233+
$this->currentReaderId = $this->getPdfReaderId($file, $parserParams);
215234
$this->objectsToCopy[$this->currentReaderId] = [];
216235

217236
$reader = $this->getPdfReader($this->currentReaderId);

src/PdfParser/CrossReference/AbstractReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This file is part of FPDI
55
*
66
* @package setasign\Fpdi
7-
* @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com)
7+
* @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com)
88
* @license http://opensource.org/licenses/mit-license The MIT License
99
*/
1010

src/PdfParser/CrossReference/CrossReference.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This file is part of FPDI
55
*
66
* @package setasign\Fpdi
7-
* @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com)
7+
* @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com)
88
* @license http://opensource.org/licenses/mit-license The MIT License
99
*/
1010

src/PdfParser/CrossReference/CrossReferenceException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This file is part of FPDI
55
*
66
* @package setasign\Fpdi
7-
* @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com)
7+
* @copyright Copyright (c) 2023 Setasign GmbH & Co. KG (https://www.setasign.com)
88
* @license http://opensource.org/licenses/mit-license The MIT License
99
*/
1010

0 commit comments

Comments
 (0)