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
|
|
|
/** |
86
|
|
|
* Whether to attempt to read PDFs even if they are marked as encrypted. |
87
|
|
|
* |
88
|
|
|
* @var bool |
89
|
|
|
*/ |
90
|
|
|
private $ignoreEncryption = false; |
91
|
|
|
|
92
|
46 |
|
public function getFontSpaceLimit() |
93
|
|
|
{ |
94
|
46 |
|
return $this->fontSpaceLimit; |
95
|
|
|
} |
96
|
|
|
|
97
|
3 |
|
public function setFontSpaceLimit($value) |
98
|
|
|
{ |
99
|
3 |
|
$this->fontSpaceLimit = $value; |
100
|
|
|
} |
101
|
|
|
|
102
|
1 |
|
public function getHorizontalOffset(): string |
103
|
|
|
{ |
104
|
1 |
|
return $this->horizontalOffset; |
105
|
|
|
} |
106
|
|
|
|
107
|
2 |
|
public function setHorizontalOffset($value): void |
108
|
|
|
{ |
109
|
2 |
|
$this->horizontalOffset = $value; |
110
|
|
|
} |
111
|
|
|
|
112
|
66 |
|
public function getPdfWhitespaces(): string |
113
|
|
|
{ |
114
|
66 |
|
return $this->pdfWhitespaces; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function setPdfWhitespaces(string $pdfWhitespaces): void |
118
|
|
|
{ |
119
|
|
|
$this->pdfWhitespaces = $pdfWhitespaces; |
120
|
|
|
} |
121
|
|
|
|
122
|
65 |
|
public function getPdfWhitespacesRegex(): string |
123
|
|
|
{ |
124
|
65 |
|
return $this->pdfWhitespacesRegex; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public function setPdfWhitespacesRegex(string $pdfWhitespacesRegex): void |
128
|
|
|
{ |
129
|
|
|
$this->pdfWhitespacesRegex = $pdfWhitespacesRegex; |
130
|
|
|
} |
131
|
|
|
|
132
|
67 |
|
public function getRetainImageContent(): bool |
133
|
|
|
{ |
134
|
67 |
|
return $this->retainImageContent; |
135
|
|
|
} |
136
|
|
|
|
137
|
1 |
|
public function setRetainImageContent(bool $retainImageContent): void |
138
|
|
|
{ |
139
|
1 |
|
$this->retainImageContent = $retainImageContent; |
140
|
|
|
} |
141
|
|
|
|
142
|
65 |
|
public function getDecodeMemoryLimit(): int |
143
|
|
|
{ |
144
|
65 |
|
return $this->decodeMemoryLimit; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
public function setDecodeMemoryLimit(int $decodeMemoryLimit): void |
148
|
|
|
{ |
149
|
|
|
$this->decodeMemoryLimit = $decodeMemoryLimit; |
150
|
|
|
} |
151
|
|
|
|
152
|
8 |
|
public function getDataTmFontInfoHasToBeIncluded(): bool |
153
|
|
|
{ |
154
|
8 |
|
return $this->dataTmFontInfoHasToBeIncluded; |
155
|
|
|
} |
156
|
|
|
|
157
|
2 |
|
public function setDataTmFontInfoHasToBeIncluded(bool $dataTmFontInfoHasToBeIncluded): void |
158
|
|
|
{ |
159
|
2 |
|
$this->dataTmFontInfoHasToBeIncluded = $dataTmFontInfoHasToBeIncluded; |
160
|
|
|
} |
161
|
|
|
|
162
|
2 |
|
public function getIgnoreEncryption(): bool |
163
|
|
|
{ |
164
|
2 |
|
return $this->ignoreEncryption; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @deprecated this is a temporary workaround, don't rely on it |
169
|
|
|
* @see https://github.com/smalot/pdfparser/pull/653 |
170
|
|
|
*/ |
171
|
1 |
|
public function setIgnoreEncryption(bool $ignoreEncryption): void |
172
|
|
|
{ |
173
|
1 |
|
$this->ignoreEncryption = $ignoreEncryption; |
174
|
|
|
} |
175
|
|
|
} |
176
|
|
|
|