|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @file |
|
5
|
|
|
* This file is part of the PdfParser library. |
|
6
|
|
|
* |
|
7
|
|
|
* @author Konrad Abicht <[email protected]> |
|
8
|
|
|
* |
|
9
|
|
|
* @date 2020-11-22 |
|
10
|
|
|
* |
|
11
|
|
|
* @license LGPLv3 |
|
12
|
|
|
* |
|
13
|
|
|
* @url <https://github.com/smalot/pdfparser> |
|
14
|
|
|
* |
|
15
|
|
|
* PdfParser is a pdf library written in PHP, extraction oriented. |
|
16
|
|
|
* Copyright (C) 2017 - Sébastien MALOT <[email protected]> |
|
17
|
|
|
* |
|
18
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
19
|
|
|
* it under the terms of the GNU Lesser General Public License as published by |
|
20
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
21
|
|
|
* (at your option) any later version. |
|
22
|
|
|
* |
|
23
|
|
|
* This program is distributed in the hope that it will be useful, |
|
24
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
25
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
26
|
|
|
* GNU Lesser General Public License for more details. |
|
27
|
|
|
* |
|
28
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
|
29
|
|
|
* along with this program. |
|
30
|
|
|
* If not, see <http://www.pdfparser.org/sites/default/LICENSE.txt>. |
|
31
|
|
|
*/ |
|
32
|
|
|
|
|
33
|
|
|
namespace Smalot\PdfParser; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* This class contains configurations used in various classes. You can override them |
|
37
|
|
|
* manually, in case default values aren't working. |
|
38
|
|
|
* |
|
39
|
|
|
* @see https://github.com/smalot/pdfparser/issues/305 |
|
40
|
|
|
*/ |
|
41
|
|
|
class Config |
|
42
|
|
|
{ |
|
43
|
|
|
private $fontSpaceLimit = -50; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var string |
|
47
|
|
|
*/ |
|
48
|
|
|
private $horizontalOffset = ' '; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Represents: (NUL, HT, LF, FF, CR, SP) |
|
52
|
|
|
* |
|
53
|
|
|
* @var string |
|
54
|
|
|
*/ |
|
55
|
|
|
private $pdfWhitespaces = "\0\t\n\f\r "; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Represents: (NUL, HT, LF, FF, CR, SP) |
|
59
|
|
|
* |
|
60
|
|
|
* @var string |
|
61
|
|
|
*/ |
|
62
|
|
|
private $pdfWhitespacesRegex = '[\0\t\n\f\r ]'; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Whether to retain raw image data as content or discard it to save memory |
|
66
|
|
|
* |
|
67
|
|
|
* @var bool |
|
68
|
|
|
*/ |
|
69
|
|
|
private $retainImageContent = true; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Memory limit to use when de-compressing files, in bytes. |
|
73
|
|
|
* |
|
74
|
|
|
* @var int |
|
75
|
|
|
*/ |
|
76
|
|
|
private $decodeMemoryLimit = 0; |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Whether to include font id and size in dataTm array |
|
80
|
|
|
* |
|
81
|
|
|
* @var bool |
|
82
|
|
|
*/ |
|
83
|
|
|
private $dataTmFontInfoHasToBeIncluded = false; |
|
84
|
|
|
|
|
85
|
26 |
|
/** |
|
86
|
|
|
* Whether to attempt to read PDFs even if they are marked as encrypted. |
|
87
|
26 |
|
* |
|
88
|
|
|
* @var bool |
|
89
|
|
|
*/ |
|
90
|
3 |
|
private $ignoreEncryption = false; |
|
91
|
|
|
|
|
92
|
3 |
|
public function getFontSpaceLimit() |
|
93
|
3 |
|
{ |
|
94
|
|
|
return $this->fontSpaceLimit; |
|
95
|
13 |
|
} |
|
96
|
|
|
|
|
97
|
13 |
|
public function setFontSpaceLimit($value) |
|
98
|
|
|
{ |
|
99
|
|
|
$this->fontSpaceLimit = $value; |
|
100
|
2 |
|
} |
|
101
|
|
|
|
|
102
|
2 |
|
public function getHorizontalOffset(): string |
|
103
|
2 |
|
{ |
|
104
|
|
|
return $this->horizontalOffset; |
|
105
|
42 |
|
} |
|
106
|
|
|
|
|
107
|
42 |
|
public function setHorizontalOffset($value): void |
|
108
|
|
|
{ |
|
109
|
|
|
$this->horizontalOffset = $value; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
public function getPdfWhitespaces(): string |
|
113
|
|
|
{ |
|
114
|
|
|
return $this->pdfWhitespaces; |
|
115
|
41 |
|
} |
|
116
|
|
|
|
|
117
|
41 |
|
public function setPdfWhitespaces(string $pdfWhitespaces): void |
|
118
|
|
|
{ |
|
119
|
|
|
$this->pdfWhitespaces = $pdfWhitespaces; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
public function getPdfWhitespacesRegex(): string |
|
123
|
|
|
{ |
|
124
|
|
|
return $this->pdfWhitespacesRegex; |
|
125
|
4 |
|
} |
|
126
|
|
|
|
|
127
|
4 |
|
public function setPdfWhitespacesRegex(string $pdfWhitespacesRegex): void |
|
128
|
|
|
{ |
|
129
|
|
|
$this->pdfWhitespacesRegex = $pdfWhitespacesRegex; |
|
130
|
1 |
|
} |
|
131
|
|
|
|
|
132
|
1 |
|
public function getRetainImageContent(): bool |
|
133
|
1 |
|
{ |
|
134
|
|
|
return $this->retainImageContent; |
|
135
|
41 |
|
} |
|
136
|
|
|
|
|
137
|
41 |
|
public function setRetainImageContent(bool $retainImageContent): void |
|
138
|
|
|
{ |
|
139
|
|
|
$this->retainImageContent = $retainImageContent; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
public function getDecodeMemoryLimit(): int |
|
143
|
|
|
{ |
|
144
|
|
|
return $this->decodeMemoryLimit; |
|
145
|
6 |
|
} |
|
146
|
|
|
|
|
147
|
6 |
|
public function setDecodeMemoryLimit(int $decodeMemoryLimit): void |
|
148
|
|
|
{ |
|
149
|
|
|
$this->decodeMemoryLimit = $decodeMemoryLimit; |
|
150
|
1 |
|
} |
|
151
|
|
|
|
|
152
|
1 |
|
public function getDataTmFontInfoHasToBeIncluded(): bool |
|
153
|
1 |
|
{ |
|
154
|
|
|
return $this->dataTmFontInfoHasToBeIncluded; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
public function setDataTmFontInfoHasToBeIncluded(bool $dataTmFontInfoHasToBeIncluded): void |
|
158
|
|
|
{ |
|
159
|
|
|
$this->dataTmFontInfoHasToBeIncluded = $dataTmFontInfoHasToBeIncluded; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
public function getIgnoreEncryption(): bool |
|
163
|
|
|
{ |
|
164
|
|
|
return $this->ignoreEncryption; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* @warning This is a workaround, don't rely on it, may change in the |
|
169
|
|
|
* future. Further information is in the following PR: |
|
170
|
|
|
* https://github.com/smalot/pdfparser/pull/653 |
|
171
|
|
|
*/ |
|
172
|
|
|
public function setIgnoreEncryption(bool $ignoreEncryption): void |
|
173
|
|
|
{ |
|
174
|
|
|
$this->ignoreEncryption = $ignoreEncryption; |
|
175
|
|
|
} |
|
176
|
|
|
} |
|
177
|
|
|
|