|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Mostafaznv\PdfOptimizer\Concerns; |
|
4
|
|
|
|
|
5
|
|
|
use Mostafaznv\PdfOptimizer\Attributes\Option; |
|
6
|
|
|
use Mostafaznv\PdfOptimizer\Enums\AutoRotatePages; |
|
7
|
|
|
use Mostafaznv\PdfOptimizer\Enums\ColorConversionStrategy; |
|
8
|
|
|
use Mostafaznv\PdfOptimizer\Enums\ImageDepth; |
|
9
|
|
|
use Mostafaznv\PdfOptimizer\Enums\ColorImageDownSampleType; |
|
10
|
|
|
use Mostafaznv\PdfOptimizer\Enums\ImageFilter; |
|
11
|
|
|
use Mostafaznv\PdfOptimizer\Enums\CompatibilityLevel; |
|
12
|
|
|
use Mostafaznv\PdfOptimizer\Enums\DefaultRenderingIntent; |
|
13
|
|
|
use Mostafaznv\PdfOptimizer\Enums\GrayImageDownSampleType; |
|
14
|
|
|
use Mostafaznv\PdfOptimizer\Enums\MonoImageDownSampleType; |
|
15
|
|
|
use Mostafaznv\PdfOptimizer\Enums\MonoImageFilter; |
|
16
|
|
|
use Mostafaznv\PdfOptimizer\Enums\PdfSettings; |
|
17
|
|
|
use Mostafaznv\PdfOptimizer\Enums\ProcessColorModel; |
|
18
|
|
|
use Mostafaznv\PdfOptimizer\Enums\UCRandBGInfo; |
|
19
|
|
|
use Mostafaznv\PdfOptimizer\PdfOptimizer; |
|
20
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
trait PdfOptimizerProperties |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* @var string[] |
|
26
|
|
|
*/ |
|
27
|
|
|
private array $options = [ |
|
28
|
|
|
'-sDEVICE=pdfwrite', '-dNOPAUSE', '-dQUIET', '-dBATCH' |
|
29
|
|
|
]; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var string[] |
|
33
|
|
|
*/ |
|
34
|
|
|
private array $extraOptions = []; |
|
35
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
#[Option('-dPDFSETTINGS')] |
|
38
|
|
|
private PdfSettings $pdfSettings = PdfSettings::SCREEN; |
|
39
|
|
|
|
|
40
|
|
|
#[Option('-dFastWebView')] |
|
41
|
|
|
private ?bool $fastWebView = null; |
|
42
|
|
|
|
|
43
|
|
|
#[Option('-dDetectDuplicateImages')] |
|
44
|
|
|
private bool $detectDuplicateImages = true; |
|
45
|
|
|
|
|
46
|
|
|
#[Option('-dPreserveMarkedContent')] |
|
47
|
|
|
private ?bool $preserveMarkedContent = null; |
|
48
|
|
|
|
|
49
|
|
|
#[Option('-dPDFX')] |
|
50
|
|
|
private ?bool $pdfX = null; |
|
51
|
|
|
|
|
52
|
|
|
#[Option('-dPDFA')] |
|
53
|
|
|
private ?int $pdfA = null; |
|
54
|
|
|
|
|
55
|
|
|
#[Option('-dPDFACompatibilityPolicy')] |
|
56
|
|
|
private ?int $pdfACompatibilityPolicy = null; |
|
57
|
|
|
|
|
58
|
|
|
#[Option('-dMaxInlineImageSize')] |
|
59
|
|
|
private ?int $maxInlineImageSize = null; |
|
60
|
|
|
|
|
61
|
|
|
#[Option('-dEmbedAllFonts')] |
|
62
|
|
|
private ?bool $embedAllFonts = null; |
|
63
|
|
|
|
|
64
|
|
|
#[Option('-dSubsetFonts')] |
|
65
|
|
|
private ?bool $subsetFonts = null; |
|
66
|
|
|
|
|
67
|
|
|
#[Option('-dCompressFonts')] |
|
68
|
|
|
private ?bool $compressFonts = null; |
|
69
|
|
|
|
|
70
|
|
|
#[Option('-dConvertCMYKImagesToRGB')] |
|
71
|
|
|
private ?bool $convertCmykImagesToRGB = null; |
|
72
|
|
|
|
|
73
|
|
|
#[Option('-dDownsampleColorImages')] |
|
74
|
|
|
private ?bool $downSampleColorImages = null; |
|
75
|
|
|
|
|
76
|
|
|
#[Option('-dDownsampleGrayImages')] |
|
77
|
|
|
private ?bool $downSampleGrayImages = null; |
|
78
|
|
|
|
|
79
|
|
|
#[Option('-dDownsampleMonoImages')] |
|
80
|
|
|
private ?bool $downSampleMonoImages = null; |
|
81
|
|
|
|
|
82
|
|
|
#[Option('-dColorImageResolution')] |
|
83
|
|
|
private ?int $colorImageResolution = null; |
|
84
|
|
|
|
|
85
|
|
|
#[Option('-dGrayImageResolution')] |
|
86
|
|
|
private ?int $grayImageResolution = null; |
|
87
|
|
|
|
|
88
|
|
|
#[Option('-dMonoImageResolution')] |
|
89
|
|
|
private ?int $monoImageResolution = null; |
|
90
|
|
|
|
|
91
|
|
|
#[Option('-dPreserveEPSInfo')] |
|
92
|
|
|
private ?bool $preserveEpsInfo = null; |
|
93
|
|
|
|
|
94
|
|
|
#[Option('-dPreserveOPIComments')] |
|
95
|
|
|
private ?bool $preserveOpiComments = null; |
|
96
|
|
|
|
|
97
|
|
|
#[Option('-dASCII85EncodePages')] |
|
98
|
|
|
private ?bool $ascii85EncodePages = null; |
|
99
|
|
|
|
|
100
|
|
|
#[Option('-dAutoFilterColorImages')] |
|
101
|
|
|
private ?bool $autoFilterColorImages = null; |
|
102
|
|
|
|
|
103
|
|
|
#[Option('-dAutoFilterGrayImages')] |
|
104
|
|
|
private ?bool $autoFilterGrayImages = null; |
|
105
|
|
|
|
|
106
|
|
|
#[Option('-dColorImageDownsampleThreshold')] |
|
107
|
|
|
private ?float $colorImageDownSampleThreshold = null; |
|
108
|
|
|
|
|
109
|
|
|
#[Option('-dGrayImageDownsampleThreshold')] |
|
110
|
|
|
private ?float $grayImageDownSampleThreshold = null; |
|
111
|
|
|
|
|
112
|
|
|
#[Option('-dMonoImageDownsampleThreshold')] |
|
113
|
|
|
private ?float $monoImageDownSampleThreshold = null; |
|
114
|
|
|
|
|
115
|
|
|
#[Option('-dCompressPages')] |
|
116
|
|
|
private ?bool $compressPages = null; |
|
117
|
|
|
|
|
118
|
|
|
#[Option('-dEncodeColorImages')] |
|
119
|
|
|
private ?bool $encodeColorImages = null; |
|
120
|
|
|
|
|
121
|
|
|
#[Option('-dEncodeGrayImages')] |
|
122
|
|
|
private ?bool $encodeGrayImages = null; |
|
123
|
|
|
|
|
124
|
|
|
#[Option('-dEncodeMonoImages')] |
|
125
|
|
|
private ?bool $encodeMonoImages = null; |
|
126
|
|
|
|
|
127
|
|
|
#[Option('-dLockDistillerParams')] |
|
128
|
|
|
private ?bool $lockDistillerParams = null; |
|
129
|
|
|
|
|
130
|
|
|
#[Option('-dMaxSubsetPct')] |
|
131
|
|
|
private ?int $maxSubsetPct = null; |
|
132
|
|
|
|
|
133
|
|
|
#[Option('-dParseDSCComments')] |
|
134
|
|
|
private ?bool $parseDscComments = null; |
|
135
|
|
|
|
|
136
|
|
|
#[Option('-dParseDSCCommentsForDocInfo')] |
|
137
|
|
|
private ?bool $parseDscCommentsForDocInfo = null; |
|
138
|
|
|
|
|
139
|
|
|
#[Option('-dPreserveHalftoneInfo')] |
|
140
|
|
|
private ?bool $preserveHalftoneInfo = null; |
|
141
|
|
|
|
|
142
|
|
|
#[Option('-dPreserveOverprintSettings')] |
|
143
|
|
|
private ?bool $preserveOverprintSettings = null; |
|
144
|
|
|
|
|
145
|
|
|
#[Option('-dUseFlateCompression')] |
|
146
|
|
|
private ?bool $useFlateCompression = null; |
|
147
|
|
|
|
|
148
|
|
|
#[Option('-dPassThroughJPEGImages')] |
|
149
|
|
|
private ?bool $passThroughJpegImages = null; |
|
150
|
|
|
|
|
151
|
|
|
#[Option('-dPassThroughJPXImages')] |
|
152
|
|
|
private ?bool $passThroughJpxImages = null; |
|
153
|
|
|
|
|
154
|
|
|
#[Option('-dCompatibilityLevel')] |
|
155
|
|
|
private ?CompatibilityLevel $compatibilityLevel = null; |
|
156
|
|
|
|
|
157
|
|
|
#[Option('-sProcessColorModel')] |
|
158
|
|
|
private ?ProcessColorModel $processColorModel = null; |
|
159
|
|
|
|
|
160
|
|
|
#[Option('-sColorConversionStrategy')] |
|
161
|
|
|
private ?ColorConversionStrategy $colorConversionStrategy = null; |
|
162
|
|
|
|
|
163
|
|
|
#[Option('-dUCRandBGInfo')] |
|
164
|
|
|
private ?UCRandBGInfo $ucRandBbInfo = null; |
|
165
|
|
|
|
|
166
|
|
|
#[Option('-dAutoRotatePages')] |
|
167
|
|
|
private ?AutoRotatePages $autoRotatePages = null; |
|
168
|
|
|
|
|
169
|
|
|
#[Option('-dColorImageDownsampleType')] |
|
170
|
|
|
private ?ColorImageDownSampleType $colorImageDownSampleType = null; |
|
171
|
|
|
|
|
172
|
|
|
#[Option('-dGrayImageDownsampleType')] |
|
173
|
|
|
private ?GrayImageDownSampleType $grayImageDownSampleType = null; |
|
174
|
|
|
|
|
175
|
|
|
#[Option('-dMonoImageDownsampleType')] |
|
176
|
|
|
private ?MonoImageDownSampleType $monoImageDownSampleType = null; |
|
177
|
|
|
|
|
178
|
|
|
#[Option('-dColorImageDepth')] |
|
179
|
|
|
private ?ImageDepth $colorImageDepth = null; |
|
180
|
|
|
|
|
181
|
|
|
#[Option('-dGrayImageDepth')] |
|
182
|
|
|
private ?ImageDepth $grayImageDepth = null; |
|
183
|
|
|
|
|
184
|
|
|
#[Option('-dMonoImageDepth')] |
|
185
|
|
|
private ?ImageDepth $monoImageDepth = null; |
|
186
|
|
|
|
|
187
|
|
|
#[Option('-dColorImageFilter')] |
|
188
|
|
|
private ?ImageFilter $colorImageFilter = null; |
|
189
|
|
|
|
|
190
|
|
|
#[Option('-dGrayImageFilter')] |
|
191
|
|
|
private ?ImageFilter $grayImageFilter = null; |
|
192
|
|
|
|
|
193
|
|
|
#[Option('-dMonoImageFilter')] |
|
194
|
|
|
private ?MonoImageFilter $monoImageFilter = null; |
|
195
|
|
|
|
|
196
|
|
|
#[Option('-dDefaultRenderingIntent')] |
|
197
|
|
|
private ?DefaultRenderingIntent $defaultRenderingIntent = null; |
|
198
|
|
|
|
|
199
|
|
|
private int $timeout = 300; |
|
200
|
|
|
|
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* #### ASCII85EncodePages |
|
204
|
|
|
* |
|
205
|
|
|
* If true, Distiller ASCII85-encodes binary streams such as page content streams, |
|
206
|
|
|
* sampled images, and embedded fonts, resulting in a PDF file that is pure ASCII. |
|
207
|
|
|
* If false, Distiller does not encode the binary streams, resulting in a PDF file |
|
208
|
|
|
* that may contain substantial amounts of binary data. |
|
209
|
|
|
* |
|
210
|
|
|
* Distiller checks the value of this setting only once per document. Any change to |
|
211
|
|
|
* it must be made before any marks are placed on the first page of the document. |
|
212
|
|
|
* |
|
213
|
|
|
* @param bool $status |
|
214
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
215
|
|
|
*/ |
|
216
|
|
|
public function ascii85EncodePages(bool $status = true): self |
|
217
|
|
|
{ |
|
218
|
|
|
$this->ascii85EncodePages = $status; |
|
219
|
|
|
|
|
220
|
|
|
return $this; |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
/** |
|
224
|
|
|
* #### AutoFilterColorImages |
|
225
|
|
|
* |
|
226
|
|
|
* If true, the compression filter for color images is chosen based on the properties of |
|
227
|
|
|
* each image, in conjunction with the `ColorImageAutoFilterStrategy` setting. |
|
228
|
|
|
* If false, all color sampled images are compressed using the filter specified by ColorImageFilter. |
|
229
|
|
|
* |
|
230
|
|
|
* This setting is relevant only if EncodeColorImages is true. |
|
231
|
|
|
* |
|
232
|
|
|
* @param bool $status |
|
233
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
234
|
|
|
*/ |
|
235
|
|
|
public function autoFilterColorImages(bool $status = true): self |
|
236
|
|
|
{ |
|
237
|
|
|
$this->autoFilterColorImages = $status; |
|
238
|
|
|
|
|
239
|
|
|
return $this; |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
|
|
/** |
|
243
|
|
|
* #### AutoFilterGrayImages |
|
244
|
|
|
* |
|
245
|
|
|
* If true, the compression filter for gray images is chosen based on the properties of |
|
246
|
|
|
* each image, in conjunction with the GrayImageAutoFilterStrategy setting. |
|
247
|
|
|
* If false, all color sampled images are compressed using the filter specified by |
|
248
|
|
|
* GrayImageFilter. |
|
249
|
|
|
* |
|
250
|
|
|
* This setting is relevant only if EncodeGrayImages is true. |
|
251
|
|
|
* |
|
252
|
|
|
* @param bool $status |
|
253
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
254
|
|
|
*/ |
|
255
|
|
|
public function autoFilterGrayImages(bool $status = true): self |
|
256
|
|
|
{ |
|
257
|
|
|
$this->autoFilterGrayImages = $status; |
|
258
|
|
|
|
|
259
|
|
|
return $this; |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
/** |
|
263
|
|
|
* #### AutoRotatePages |
|
264
|
|
|
* |
|
265
|
|
|
* Allows Distiller to automatically orient (rotate) pages based on |
|
266
|
|
|
* the predominant text orientation. autorotation is not done if the file contains |
|
267
|
|
|
* the %%ViewingOrientation DSC comment and ParseDSCComments is true. |
|
268
|
|
|
* |
|
269
|
|
|
* If AutoRotatePages is set to None, pages are not automatically oriented and |
|
270
|
|
|
* the %%ViewingOrientation DSC comment is ignored. |
|
271
|
|
|
* |
|
272
|
|
|
* @param AutoRotatePages $mode |
|
273
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
274
|
|
|
*/ |
|
275
|
|
|
public function autoRotatePages(AutoRotatePages $mode): self |
|
276
|
|
|
{ |
|
277
|
|
|
$this->autoRotatePages = $mode; |
|
278
|
|
|
|
|
279
|
|
|
return $this; |
|
280
|
|
|
} |
|
281
|
|
|
|
|
282
|
|
|
/** |
|
283
|
|
|
* #### ColorConversionStrategy |
|
284
|
|
|
* |
|
285
|
|
|
* Sets the color conversion strategy, which includes the output color family and color |
|
286
|
|
|
* space and the inclusion of ICC profiles. |
|
287
|
|
|
* |
|
288
|
|
|
* @param ColorConversionStrategy $strategy |
|
289
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
290
|
|
|
*/ |
|
291
|
|
|
public function colorConversionStrategy(ColorConversionStrategy $strategy): self |
|
292
|
|
|
{ |
|
293
|
|
|
$this->colorConversionStrategy = $strategy; |
|
294
|
|
|
|
|
295
|
|
|
return $this; |
|
296
|
|
|
} |
|
297
|
|
|
|
|
298
|
|
|
/** |
|
299
|
|
|
* #### ColorImageDepth |
|
300
|
|
|
* |
|
301
|
|
|
* Specifies the number of bits per color component in the output image. |
|
302
|
|
|
* |
|
303
|
|
|
* Allowed values are: |
|
304
|
|
|
* The number of bits per sample: 1, 2, 4, or 8. |
|
305
|
|
|
* -1 , which forces the downsampled image to have the same number of bits per color |
|
306
|
|
|
* component as the original image. |
|
307
|
|
|
* |
|
308
|
|
|
* @param ImageDepth $depth |
|
309
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
310
|
|
|
*/ |
|
311
|
|
|
public function colorImageDepth(ImageDepth $depth): self |
|
312
|
|
|
{ |
|
313
|
|
|
$this->colorImageDepth = $depth; |
|
314
|
|
|
|
|
315
|
|
|
return $this; |
|
316
|
|
|
} |
|
317
|
|
|
|
|
318
|
|
|
/** |
|
319
|
|
|
* #### ColorImageFilter |
|
320
|
|
|
* |
|
321
|
|
|
* Specifies the compression filter to be used for color images. |
|
322
|
|
|
* Ignored if AutoFilterColorImages is true or EncodeColorImages is false. |
|
323
|
|
|
* |
|
324
|
|
|
* @param ImageFilter $filter |
|
325
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
326
|
|
|
*/ |
|
327
|
|
|
public function colorImageFilter(ImageFilter $filter): self |
|
328
|
|
|
{ |
|
329
|
|
|
$this->colorImageFilter = $filter; |
|
330
|
|
|
|
|
331
|
|
|
return $this; |
|
332
|
|
|
} |
|
333
|
|
|
|
|
334
|
|
|
/** |
|
335
|
|
|
* #### ColorImageDownsampleThreshold |
|
336
|
|
|
* |
|
337
|
|
|
* Sets the downsample threshold for color images. |
|
338
|
|
|
* This is the ratio of image resolution to output resolution above which downsampling |
|
339
|
|
|
* may be performed. Must be between 1.0 through 10.0, inclusive. |
|
340
|
|
|
* |
|
341
|
|
|
* If you set the threshold out of range, it reverts to a default of 1.5. |
|
342
|
|
|
* |
|
343
|
|
|
* @param float $threshold |
|
344
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
345
|
|
|
*/ |
|
346
|
|
|
public function colorImageDownSampleThreshold(float $threshold): self |
|
347
|
|
|
{ |
|
348
|
|
|
$this->colorImageDownSampleThreshold = $threshold; |
|
349
|
|
|
|
|
350
|
|
|
return $this; |
|
351
|
|
|
} |
|
352
|
|
|
|
|
353
|
|
|
/** |
|
354
|
|
|
* #### ColorImageDownsampleType |
|
355
|
|
|
* |
|
356
|
|
|
* Must be one of the following values: |
|
357
|
|
|
* - Average (Average Downsampling to): |
|
358
|
|
|
* Groups of samples are averaged to get the new downsampled value. |
|
359
|
|
|
* - Bicubic (Bicubic Downsampling to): |
|
360
|
|
|
* Bicubic interpolation is used on a group of samples to get a new downsampled value. |
|
361
|
|
|
* - Subsample (Subsampling to): |
|
362
|
|
|
* The center sample from a group of samples is used as the new downsampled value. |
|
363
|
|
|
* |
|
364
|
|
|
* |
|
365
|
|
|
* @param ColorImageDownSampleType $type |
|
366
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
367
|
|
|
*/ |
|
368
|
|
|
public function colorImageDownSampleType(ColorImageDownSampleType $type): self |
|
369
|
|
|
{ |
|
370
|
|
|
$this->colorImageDownSampleType = $type; |
|
371
|
|
|
|
|
372
|
|
|
return $this; |
|
373
|
|
|
} |
|
374
|
|
|
|
|
375
|
|
|
/** |
|
376
|
|
|
* #### ColorImageResolution |
|
377
|
|
|
* |
|
378
|
|
|
* Specifies the resolution to which downsampled color images are reduced; |
|
379
|
|
|
* valid values are 9 to 2400 pixels per inch. |
|
380
|
|
|
* A color image is downsampled if DownsampleColorImages is true and the resolution of |
|
381
|
|
|
* the input image meets the criteria described in Downsampling and subsampling images. |
|
382
|
|
|
* |
|
383
|
|
|
* @param int $resolution |
|
384
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
385
|
|
|
*/ |
|
386
|
|
|
public function colorImageResolution(int $resolution): self |
|
387
|
|
|
{ |
|
388
|
|
|
$this->colorImageResolution = $resolution; |
|
389
|
|
|
|
|
390
|
|
|
return $this; |
|
391
|
|
|
} |
|
392
|
|
|
|
|
393
|
|
|
/** |
|
394
|
|
|
* #### CompatibilityLevel |
|
395
|
|
|
* |
|
396
|
|
|
* The PDF version number: 1.2, 1.3, 1.4, 1.5, 1.6, or 1.7. |
|
397
|
|
|
* Applications other than Distiller do not support saving files as PDF 1.2. |
|
398
|
|
|
* |
|
399
|
|
|
* @param CompatibilityLevel $compatibilityLevel |
|
400
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
401
|
|
|
*/ |
|
402
|
|
|
public function compatibilityLevel(CompatibilityLevel $compatibilityLevel): self |
|
403
|
|
|
{ |
|
404
|
|
|
$this->compatibilityLevel = $compatibilityLevel; |
|
405
|
|
|
|
|
406
|
|
|
return $this; |
|
407
|
|
|
} |
|
408
|
|
|
|
|
409
|
|
|
/** |
|
410
|
|
|
* #### CompressFonts |
|
411
|
|
|
* |
|
412
|
|
|
* Defines whether pdfwrite will compress embedded fonts in the output. |
|
413
|
|
|
* The default value is true; the false setting is intended only for debugging as |
|
414
|
|
|
* it will result in larger output. |
|
415
|
|
|
* |
|
416
|
|
|
* @param bool $status |
|
417
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
418
|
|
|
*/ |
|
419
|
|
|
public function compressFonts(bool $status = true): self |
|
420
|
|
|
{ |
|
421
|
|
|
$this->compressFonts = $status; |
|
422
|
|
|
|
|
423
|
|
|
return $this; |
|
424
|
|
|
} |
|
425
|
|
|
|
|
426
|
|
|
/** |
|
427
|
|
|
* #### CompressPages |
|
428
|
|
|
* |
|
429
|
|
|
* If true, Flate compression is used to compress page content streams as |
|
430
|
|
|
* well as form, pattern, and Type 3 font content streams. |
|
431
|
|
|
* InDesign also compresses ICC profiles, OutputIntentProfile and shading streams. |
|
432
|
|
|
* |
|
433
|
|
|
* @param bool $status |
|
434
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
435
|
|
|
*/ |
|
436
|
|
|
public function compressPages(bool $status = true): self |
|
437
|
|
|
{ |
|
438
|
|
|
$this->compressPages = $status; |
|
439
|
|
|
|
|
440
|
|
|
return $this; |
|
441
|
|
|
} |
|
442
|
|
|
|
|
443
|
|
|
/** |
|
444
|
|
|
* #### ConvertCMYKImagesToRGB |
|
445
|
|
|
* |
|
446
|
|
|
* @param bool $status |
|
447
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
448
|
|
|
*/ |
|
449
|
|
|
public function convertCmykImagesToRGB(bool $status = true): self |
|
450
|
|
|
{ |
|
451
|
|
|
$this->convertCmykImagesToRGB = $status; |
|
452
|
|
|
|
|
453
|
|
|
return $this; |
|
454
|
|
|
} |
|
455
|
|
|
|
|
456
|
|
|
/** |
|
457
|
|
|
* #### DefaultRenderingIntent |
|
458
|
|
|
* |
|
459
|
|
|
* Specifies the rendering intent for objects to be written to the PDF document, when |
|
460
|
|
|
* not otherwise specified in the PostScript job by means of the findcolorrendering and |
|
461
|
|
|
* setcolorrendering operators. |
|
462
|
|
|
* |
|
463
|
|
|
* @param DefaultRenderingIntent $renderingIntent |
|
464
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
465
|
|
|
*/ |
|
466
|
|
|
public function defaultRenderingIntent(DefaultRenderingIntent $renderingIntent): self |
|
467
|
|
|
{ |
|
468
|
|
|
$this->defaultRenderingIntent = $renderingIntent; |
|
469
|
|
|
|
|
470
|
|
|
return $this; |
|
471
|
|
|
} |
|
472
|
|
|
|
|
473
|
|
|
/** |
|
474
|
|
|
* #### DetectDuplicateImages |
|
475
|
|
|
* |
|
476
|
|
|
* Takes a Boolean argument, when set to true (the default) pdfwrite will compare all |
|
477
|
|
|
* new images with all the images encountered to date (NOT small images which are |
|
478
|
|
|
* stored in-line) to see if the new image is a duplicate of an earlier one. |
|
479
|
|
|
* If it is a duplicate then instead of writing a new image into the PDF file, |
|
480
|
|
|
* the PDF will reuse the reference to the earlier image. This can considerably reduce |
|
481
|
|
|
* the size of the output PDF file, but increases the time taken to process the file. |
|
482
|
|
|
* |
|
483
|
|
|
* This time grows exponentially as more images are added, and on large input files with |
|
484
|
|
|
* numerous images can be prohibitively slow. Setting this to false will improve |
|
485
|
|
|
* performance at the cost of final file size. |
|
486
|
|
|
* |
|
487
|
|
|
* @param bool $status |
|
488
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
489
|
|
|
*/ |
|
490
|
|
|
public function detectDuplicateImages(bool $status = true): self |
|
491
|
|
|
{ |
|
492
|
|
|
$this->detectDuplicateImages = $status; |
|
493
|
|
|
|
|
494
|
|
|
return $this; |
|
495
|
|
|
} |
|
496
|
|
|
|
|
497
|
|
|
/** |
|
498
|
|
|
* #### DownsampleColorImages |
|
499
|
|
|
* |
|
500
|
|
|
* If true, color images are downsampled using the resolution specified by ColorImageResolution, |
|
501
|
|
|
* assuming the threshold specified by ColorImageDownsampleThreshold is met. |
|
502
|
|
|
* If false, downsampling is not done and the resolution of color images in the |
|
503
|
|
|
* PDF file is the same as the source images. |
|
504
|
|
|
* |
|
505
|
|
|
* @param bool $status |
|
506
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
507
|
|
|
*/ |
|
508
|
|
|
public function downSampleColorImages(bool $status = true): self |
|
509
|
|
|
{ |
|
510
|
|
|
$this->downSampleColorImages = $status; |
|
511
|
|
|
|
|
512
|
|
|
return $this; |
|
513
|
|
|
} |
|
514
|
|
|
|
|
515
|
|
|
/** |
|
516
|
|
|
* #### DownsampleGrayImages |
|
517
|
|
|
* |
|
518
|
|
|
* If true, grayscale images are downsampled using the resolution specified by GrayImageResolution. |
|
519
|
|
|
* If false, downsampling does not occur, and the resolution of grayscale images in |
|
520
|
|
|
* the PDF file is the same as the source images. |
|
521
|
|
|
* |
|
522
|
|
|
* @param bool $status |
|
523
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
524
|
|
|
*/ |
|
525
|
|
|
public function downSampleGrayImages(bool $status = true): self |
|
526
|
|
|
{ |
|
527
|
|
|
$this->downSampleGrayImages = $status; |
|
528
|
|
|
|
|
529
|
|
|
return $this; |
|
530
|
|
|
} |
|
531
|
|
|
|
|
532
|
|
|
/** |
|
533
|
|
|
* #### DownsampleMonoImages |
|
534
|
|
|
* |
|
535
|
|
|
* If true, monochrome images are downsampled using the resolution specified by MonoImageResolution. |
|
536
|
|
|
* If false, downsampling is not done and the resolution of monochrome images in |
|
537
|
|
|
* the PDF file is the same as the source images. |
|
538
|
|
|
* |
|
539
|
|
|
* @param bool $status |
|
540
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
541
|
|
|
*/ |
|
542
|
|
|
public function downSampleMonoImages(bool $status = true): self |
|
543
|
|
|
{ |
|
544
|
|
|
$this->downSampleMonoImages = $status; |
|
545
|
|
|
|
|
546
|
|
|
return $this; |
|
547
|
|
|
} |
|
548
|
|
|
|
|
549
|
|
|
/** |
|
550
|
|
|
* #### EmbedAllFonts |
|
551
|
|
|
* |
|
552
|
|
|
* If true, all fonts that have correct permissions are embedded in the PDF file; |
|
553
|
|
|
* if false, they are not embedded: |
|
554
|
|
|
* - Creative Suite applications automatically embed fonts. |
|
555
|
|
|
* - Distiller never embeds fonts in its NeverEmbed list even if this setting is true. |
|
556
|
|
|
* |
|
557
|
|
|
* @param bool $status |
|
558
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
559
|
|
|
*/ |
|
560
|
|
|
public function embedAllFonts(bool $status = true): self |
|
561
|
|
|
{ |
|
562
|
|
|
$this->embedAllFonts = $status; |
|
563
|
|
|
|
|
564
|
|
|
return $this; |
|
565
|
|
|
} |
|
566
|
|
|
|
|
567
|
|
|
/** |
|
568
|
|
|
* #### EncodeColorImages |
|
569
|
|
|
* |
|
570
|
|
|
* If true, color images are encoded using the compression filter specified by the |
|
571
|
|
|
* value of ColorImageFilter. |
|
572
|
|
|
* If false, compression filters are not applied to color images. |
|
573
|
|
|
* |
|
574
|
|
|
* @param bool $status |
|
575
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
576
|
|
|
*/ |
|
577
|
|
|
public function encodeColorImages(bool $status = true): self |
|
578
|
|
|
{ |
|
579
|
|
|
$this->encodeColorImages = $status; |
|
580
|
|
|
|
|
581
|
|
|
return $this; |
|
582
|
|
|
} |
|
583
|
|
|
|
|
584
|
|
|
/** |
|
585
|
|
|
* #### EncodeGrayImages |
|
586
|
|
|
* |
|
587
|
|
|
* If true, grayscale images are encoded using the compression filter specified by the |
|
588
|
|
|
* value of GrayImageFilter. |
|
589
|
|
|
* If false, compression filters are not applied to grayscale sampled images. |
|
590
|
|
|
* |
|
591
|
|
|
* @param bool $status |
|
592
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
593
|
|
|
*/ |
|
594
|
|
|
public function encodeGrayImages(bool $status = true): self |
|
595
|
|
|
{ |
|
596
|
|
|
$this->encodeGrayImages = $status; |
|
597
|
|
|
|
|
598
|
|
|
return $this; |
|
599
|
|
|
} |
|
600
|
|
|
|
|
601
|
|
|
/** |
|
602
|
|
|
* #### EncodeMonoImages |
|
603
|
|
|
* |
|
604
|
|
|
* If true, monochrome images are encoded using the compression filter specified by |
|
605
|
|
|
* the value of MonoImageFilter. |
|
606
|
|
|
* If false, no compression filters are applied to monochrome images. |
|
607
|
|
|
* |
|
608
|
|
|
* @param bool $status |
|
609
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
610
|
|
|
*/ |
|
611
|
|
|
public function encodeMonoImages(bool $status = true): self |
|
612
|
|
|
{ |
|
613
|
|
|
$this->encodeMonoImages = $status; |
|
614
|
|
|
|
|
615
|
|
|
return $this; |
|
616
|
|
|
} |
|
617
|
|
|
|
|
618
|
|
|
/** |
|
619
|
|
|
* #### FastWebView |
|
620
|
|
|
* |
|
621
|
|
|
* Takes a Boolean argument, default is false. When set to true pdfwrite will reorder |
|
622
|
|
|
* the output PDF file to conform to the Adobe ‘linearised’ PDF specification. |
|
623
|
|
|
* The Acrobat user interface refers to this as ‘Optimised for Fast Web Viewing’. |
|
624
|
|
|
* |
|
625
|
|
|
* Note that this will cause the conversion to PDF to be slightly slower and will usually |
|
626
|
|
|
* result in a slightly larger PDF file. This option is incompatible with producing an |
|
627
|
|
|
* encrypted (password protected) PDF file. |
|
628
|
|
|
* |
|
629
|
|
|
* @param bool $status |
|
630
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
631
|
|
|
*/ |
|
632
|
|
|
public function fastWebView(bool $status = true): self |
|
633
|
|
|
{ |
|
634
|
|
|
$this->fastWebView = $status; |
|
635
|
|
|
|
|
636
|
|
|
return $this; |
|
637
|
|
|
} |
|
638
|
|
|
|
|
639
|
|
|
/** |
|
640
|
|
|
* #### GrayImageDepth |
|
641
|
|
|
* |
|
642
|
|
|
* Specifies the number of bits per sample in the image. The following values are valid: |
|
643
|
|
|
* - The number of bits per sample: 1 , 2 , 4 , or 8. |
|
644
|
|
|
* - -1 , which forces the downsampled image to have the same number of bits per sample as the original image |
|
645
|
|
|
* |
|
646
|
|
|
* @param ImageDepth $depth |
|
647
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
648
|
|
|
*/ |
|
649
|
|
|
public function grayImageDepth(ImageDepth $depth): self |
|
650
|
|
|
{ |
|
651
|
|
|
$this->grayImageDepth = $depth; |
|
652
|
|
|
|
|
653
|
|
|
return $this; |
|
654
|
|
|
} |
|
655
|
|
|
|
|
656
|
|
|
/** |
|
657
|
|
|
* #### GrayImageDownsampleThreshold |
|
658
|
|
|
* |
|
659
|
|
|
* Sets the image downsample threshold for grayscale images. This is the ratio of image |
|
660
|
|
|
* resolution to output resolution above which downsampling may be performed. |
|
661
|
|
|
* |
|
662
|
|
|
* @param float $threshold |
|
663
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
664
|
|
|
*/ |
|
665
|
|
|
public function grayImageDownSampleThreshold(float $threshold): self |
|
666
|
|
|
{ |
|
667
|
|
|
$this->grayImageDownSampleThreshold = $threshold; |
|
668
|
|
|
|
|
669
|
|
|
return $this; |
|
670
|
|
|
} |
|
671
|
|
|
|
|
672
|
|
|
/** |
|
673
|
|
|
* #### GrayImageDownsampleType |
|
674
|
|
|
* |
|
675
|
|
|
* Must be one of the following values: |
|
676
|
|
|
* - Average (Average Downsampling to): |
|
677
|
|
|
* Groups of samples are averaged to get the new downsampled value. |
|
678
|
|
|
* - Bicubic (Bicubic Downsampling to): |
|
679
|
|
|
* Bicubic interpolation is used on a group of samples to get a new downsampled value. |
|
680
|
|
|
* - Subsample (Subsampling to): |
|
681
|
|
|
* The center sample from a group of samples is used as the new downsampled value. |
|
682
|
|
|
* |
|
683
|
|
|
* @param GrayImageDownSampleType $type |
|
684
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
685
|
|
|
*/ |
|
686
|
|
|
public function grayImageDownSampleType(GrayImageDownSampleType $type): self |
|
687
|
|
|
{ |
|
688
|
|
|
$this->grayImageDownSampleType = $type; |
|
689
|
|
|
|
|
690
|
|
|
return $this; |
|
691
|
|
|
} |
|
692
|
|
|
|
|
693
|
|
|
/** |
|
694
|
|
|
* #### GrayImageFilter |
|
695
|
|
|
* |
|
696
|
|
|
* Specifies the compression filter to be used for grayscale images. |
|
697
|
|
|
* Ignored if AutoFilterGrayImages is true or EncodeGrayImages is false. |
|
698
|
|
|
* |
|
699
|
|
|
* @param ImageFilter $filter |
|
700
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
701
|
|
|
*/ |
|
702
|
|
|
public function grayImageFilter(ImageFilter $filter): self |
|
703
|
|
|
{ |
|
704
|
|
|
$this->grayImageFilter = $filter; |
|
705
|
|
|
|
|
706
|
|
|
return $this; |
|
707
|
|
|
} |
|
708
|
|
|
|
|
709
|
|
|
/** |
|
710
|
|
|
* #### GrayImageResolution |
|
711
|
|
|
* |
|
712
|
|
|
* Specifies the resolution to which downsampled gray images are reduced. |
|
713
|
|
|
* Valid values are 9 to 2400 pixels per inch. A gray image is downsampled if |
|
714
|
|
|
* DownsampleGrayImages is true and the resolution of the input image meets the |
|
715
|
|
|
* criteria described in Downsampling and subsampling images. |
|
716
|
|
|
* |
|
717
|
|
|
* @param int $resolution |
|
718
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
719
|
|
|
*/ |
|
720
|
|
|
public function grayImageResolution(int $resolution): self |
|
721
|
|
|
{ |
|
722
|
|
|
$this->grayImageResolution = $resolution; |
|
723
|
|
|
|
|
724
|
|
|
return $this; |
|
725
|
|
|
} |
|
726
|
|
|
|
|
727
|
|
|
/** |
|
728
|
|
|
* #### LockDistillerParams |
|
729
|
|
|
* |
|
730
|
|
|
* If true, Distiller ignores any settings specified by setdistillerparams operators |
|
731
|
|
|
* in the incoming PostScript file and uses only those settings present in the |
|
732
|
|
|
* Adobe PDF settings file (or their default values if not present). |
|
733
|
|
|
* |
|
734
|
|
|
* If false, any settings specified in the PostScript file override the initial settings. |
|
735
|
|
|
* These settings are in effect for the duration of the current save level. |
|
736
|
|
|
* |
|
737
|
|
|
* @param bool $status |
|
738
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
739
|
|
|
*/ |
|
740
|
|
|
public function lockDistillerParams(bool $status = true): self |
|
741
|
|
|
{ |
|
742
|
|
|
$this->lockDistillerParams = $status; |
|
743
|
|
|
|
|
744
|
|
|
return $this; |
|
745
|
|
|
} |
|
746
|
|
|
|
|
747
|
|
|
/** |
|
748
|
|
|
* #### MaxInlineImageSize |
|
749
|
|
|
* |
|
750
|
|
|
* Specifies the maximum size of an inline image, in bytes. For images larger than this |
|
751
|
|
|
* size, pdfwrite will create an XObject instead of embedding the image into the context |
|
752
|
|
|
* stream. |
|
753
|
|
|
* The default value is 4000. |
|
754
|
|
|
* |
|
755
|
|
|
* Note that redundant inline images must be embedded each time they occur in the |
|
756
|
|
|
* document, while multiple references can be made to a single XObject image. |
|
757
|
|
|
* Therefore, it may be advantageous to set a small or zero value if the source document |
|
758
|
|
|
* is expected to contain multiple identical images, reducing the size of the generated PDF. |
|
759
|
|
|
* |
|
760
|
|
|
* @param int $size |
|
761
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
762
|
|
|
*/ |
|
763
|
|
|
public function maxInlineImageSize(int $size): self |
|
764
|
|
|
{ |
|
765
|
|
|
$this->maxInlineImageSize = $size; |
|
766
|
|
|
|
|
767
|
|
|
return $this; |
|
768
|
|
|
} |
|
769
|
|
|
|
|
770
|
|
|
/** |
|
771
|
|
|
* #### MaxSubsetPct |
|
772
|
|
|
* |
|
773
|
|
|
* The maximum percentage of glyphs in a font that can be used before the entire font is |
|
774
|
|
|
* embedded instead of a subset. |
|
775
|
|
|
* The allowable range is 1 through 100. |
|
776
|
|
|
* |
|
777
|
|
|
* Distiller only uses this value if SubsetFonts is true. For example, a value of |
|
778
|
|
|
* 30 means that a font will be embedded in full (not subset) if more than 30% of |
|
779
|
|
|
* glyphs are used; a value of 100 means all fonts will be subset no matter how many |
|
780
|
|
|
* glyphs are used (because you cannot use more than 100% of glyphs). |
|
781
|
|
|
* |
|
782
|
|
|
* @param int $max |
|
783
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
784
|
|
|
*/ |
|
785
|
|
|
public function maxSubsetPct(int $max): self |
|
786
|
|
|
{ |
|
787
|
|
|
$this->maxSubsetPct = $max; |
|
788
|
|
|
|
|
789
|
|
|
return $this; |
|
790
|
|
|
} |
|
791
|
|
|
|
|
792
|
|
|
/** |
|
793
|
|
|
* #### MonoImageDepth |
|
794
|
|
|
* |
|
795
|
|
|
* Specifies the number of bits per sample in a downsampled image. Allowed values are: |
|
796
|
|
|
* - The number of bits per sample: 1 , 2 , 4 , or 8. |
|
797
|
|
|
* When the value is greater than 1, monochrome images are converted to grayscale images. |
|
798
|
|
|
* - -1 , which forces the downsampled image to have the same number of bits per sample |
|
799
|
|
|
* as the original image. (For monochrome images, this is the same as a value of 1.) |
|
800
|
|
|
* |
|
801
|
|
|
* MonoImageDepth is not used unless DownsampleMonoImages and AntiAliasMonoImages are true. |
|
802
|
|
|
* |
|
803
|
|
|
* @param ImageDepth $depth |
|
804
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
805
|
|
|
*/ |
|
806
|
|
|
public function monoImageDepth(ImageDepth $depth): self |
|
807
|
|
|
{ |
|
808
|
|
|
$this->monoImageDepth = $depth; |
|
809
|
|
|
|
|
810
|
|
|
return $this; |
|
811
|
|
|
} |
|
812
|
|
|
|
|
813
|
|
|
/** |
|
814
|
|
|
* #### MonoImageDownsampleThreshold |
|
815
|
|
|
* |
|
816
|
|
|
* Sets the image downsample threshold for monochrome images. This is the ratio of image |
|
817
|
|
|
* resolution to output resolution above which downsampling may be performed. |
|
818
|
|
|
* |
|
819
|
|
|
* @param float $threshold |
|
820
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
821
|
|
|
*/ |
|
822
|
|
|
public function monoImageDownSampleThreshold(float $threshold): self |
|
823
|
|
|
{ |
|
824
|
|
|
$this->monoImageDownSampleThreshold = $threshold; |
|
825
|
|
|
|
|
826
|
|
|
return $this; |
|
827
|
|
|
} |
|
828
|
|
|
|
|
829
|
|
|
/** |
|
830
|
|
|
* #### MonoImageDownsampleType |
|
831
|
|
|
* |
|
832
|
|
|
* Must be one of the following values: |
|
833
|
|
|
* - Average (Average Downsampling to): |
|
834
|
|
|
* Groups of samples are averaged to get the new downsampled value. |
|
835
|
|
|
* - Bicubic (Bicubic Downsampling to): |
|
836
|
|
|
* Bicubic interpolation is used on a group of samples to get a new downsampled value. |
|
837
|
|
|
* - Subsample (Subsampling to): |
|
838
|
|
|
* The center sample from a group of samples is used as the new downsampled value. |
|
839
|
|
|
* |
|
840
|
|
|
* @param MonoImageDownSampleType $type |
|
841
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
842
|
|
|
*/ |
|
843
|
|
|
public function monoImageDownSampleType(MonoImageDownSampleType $type): self |
|
844
|
|
|
{ |
|
845
|
|
|
$this->monoImageDownSampleType = $type; |
|
846
|
|
|
|
|
847
|
|
|
return $this; |
|
848
|
|
|
} |
|
849
|
|
|
|
|
850
|
|
|
/** |
|
851
|
|
|
* #### MonoImageFilter |
|
852
|
|
|
* |
|
853
|
|
|
* Specifies the compression filter to be used for monochrome images. |
|
854
|
|
|
* Must be one of the following values: |
|
855
|
|
|
* - CCITTFaxEncode: |
|
856
|
|
|
* Selects CCITT Group 3 or 4 facsimile encoding |
|
857
|
|
|
* - FlateEncode: |
|
858
|
|
|
* Selects Flate (ZIP) compression |
|
859
|
|
|
* - RunLengthEncode: |
|
860
|
|
|
* Selects run length encoding |
|
861
|
|
|
* |
|
862
|
|
|
* @param MonoImageFilter $filter |
|
863
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
864
|
|
|
*/ |
|
865
|
|
|
public function monoImageFilter(MonoImageFilter $filter): self |
|
866
|
|
|
{ |
|
867
|
|
|
$this->monoImageFilter = $filter; |
|
868
|
|
|
|
|
869
|
|
|
return $this; |
|
870
|
|
|
} |
|
871
|
|
|
|
|
872
|
|
|
/** |
|
873
|
|
|
* #### MonoImageResolution |
|
874
|
|
|
* |
|
875
|
|
|
* Specifies the resolution to which downsampled monochrome images are reduced; |
|
876
|
|
|
* valid values are 9 to 2400 pixels per inch. |
|
877
|
|
|
* |
|
878
|
|
|
* A monochrome image is downsampled if DownsampleMonoImages is true and |
|
879
|
|
|
* the resolution of the input image meets the criteria |
|
880
|
|
|
* |
|
881
|
|
|
* @param int $resolution |
|
882
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
883
|
|
|
*/ |
|
884
|
|
|
public function monoImageResolution(int $resolution): self |
|
885
|
|
|
{ |
|
886
|
|
|
$this->monoImageResolution = $resolution; |
|
887
|
|
|
|
|
888
|
|
|
return $this; |
|
889
|
|
|
} |
|
890
|
|
|
|
|
891
|
|
|
/** |
|
892
|
|
|
* #### PassThroughJPEGImages |
|
893
|
|
|
* |
|
894
|
|
|
* If true, JPEG images (images that are already compressed with the DCTEncode filter) |
|
895
|
|
|
* are “passed through” Distiller without re-compressing them. (Distiller does perform |
|
896
|
|
|
* a decompression to ensure that images are not corrupt, but then passes the |
|
897
|
|
|
* original compressed image to the PDF file.) Images that are not compressed will |
|
898
|
|
|
* still be compressed according to the image settings in effect for the type of |
|
899
|
|
|
* image (for example, ColorImageFilter , etc.). |
|
900
|
|
|
* |
|
901
|
|
|
* If false, all JPEG encoded images are decompressed and recompressed according the |
|
902
|
|
|
* compression settings in effect. |
|
903
|
|
|
* |
|
904
|
|
|
* Note, however, that JPEG images that meet the following criteria are not passed |
|
905
|
|
|
* through even if the value of PassThroughJPEGImages is true: |
|
906
|
|
|
* - The image will be downsampled. |
|
907
|
|
|
* - ColorConversionStrategy is sRGB and the current PostScript color space (for the image) is not DeviceRGB or DeviceGray. |
|
908
|
|
|
* - The image will be cropped—i.e., the clip path is such that more than 10% of the image pixels will be removed. |
|
909
|
|
|
* |
|
910
|
|
|
* Creative Suite applications do not use this setting. However, Illustrator and |
|
911
|
|
|
* InDesign normally behave as if it were true with regard to placed PDF files |
|
912
|
|
|
* containing compressed images. That is, they do not normally uncompress and |
|
913
|
|
|
* recompress them, unless color conversion or downsampling takes place. |
|
914
|
|
|
* |
|
915
|
|
|
* @param bool $status |
|
916
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
917
|
|
|
*/ |
|
918
|
|
|
public function passThroughJpegImages(bool $status = true): self |
|
919
|
|
|
{ |
|
920
|
|
|
$this->passThroughJpegImages = $status; |
|
921
|
|
|
|
|
922
|
|
|
return $this; |
|
923
|
|
|
} |
|
924
|
|
|
|
|
925
|
|
|
/** |
|
926
|
|
|
* #### PassThroughJPXImages |
|
927
|
|
|
* |
|
928
|
|
|
* When true image data in the source which is encoded using the JPX (JPEG 2000) filter |
|
929
|
|
|
* will not be decompressed and then recompressed on output. This prevents the |
|
930
|
|
|
* multiplication of JPEG artefacts caused by lossy compression. PassThroughJPXImages |
|
931
|
|
|
* currently only affects simple JPX encoded images. It has no effect on JPEG encoded |
|
932
|
|
|
* images (see above) or masked images. In addition, this parameter will be ignored if |
|
933
|
|
|
* the pdfwrite device needs to modify the source data. This can happen if the image is |
|
934
|
|
|
* being downsampled, changing colour space or having transfer functions applied. |
|
935
|
|
|
* Note that this parameter essentially overrides the EncodeColorImages and |
|
936
|
|
|
* EncodeGrayImages parameters if they are false, the image will still be written with |
|
937
|
|
|
* a JPXDecode filter. NB this feature currently only works with PostScript or PDF |
|
938
|
|
|
* input, it does not work with PCL, PXL or XPS input. |
|
939
|
|
|
* |
|
940
|
|
|
* @param bool $status |
|
941
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
942
|
|
|
*/ |
|
943
|
|
|
public function passThroughJpxImages(bool $status = true): self |
|
944
|
|
|
{ |
|
945
|
|
|
$this->passThroughJpxImages = $status; |
|
946
|
|
|
|
|
947
|
|
|
return $this; |
|
948
|
|
|
} |
|
949
|
|
|
|
|
950
|
|
|
/** |
|
951
|
|
|
* #### ParseDSCComments |
|
952
|
|
|
* |
|
953
|
|
|
* If true, Distiller parses the DSC comments for any information that might be helpful |
|
954
|
|
|
* for distilling the file or for information that is passed into the PDF file. |
|
955
|
|
|
* If false, Distiller treats the DSC comments as pure PostScript comments and ignores them. |
|
956
|
|
|
* |
|
957
|
|
|
* @param bool $status |
|
958
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
959
|
|
|
*/ |
|
960
|
|
|
public function parseDscComments(bool $status = true): self |
|
961
|
|
|
{ |
|
962
|
|
|
$this->parseDscComments = $status; |
|
963
|
|
|
|
|
964
|
|
|
return $this; |
|
965
|
|
|
} |
|
966
|
|
|
|
|
967
|
|
|
/** |
|
968
|
|
|
* #### ParseDSCCommentsForDocInfo |
|
969
|
|
|
* |
|
970
|
|
|
* If true, Distiller attempts to preserve the Document Information from the |
|
971
|
|
|
* PostScript DSC comments as properties of the PDF document. |
|
972
|
|
|
* |
|
973
|
|
|
* @param bool $status |
|
974
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
975
|
|
|
*/ |
|
976
|
|
|
public function parseDscCommentsForDocInfo(bool $status = true): self |
|
977
|
|
|
{ |
|
978
|
|
|
$this->parseDscCommentsForDocInfo = $status; |
|
979
|
|
|
|
|
980
|
|
|
return $this; |
|
981
|
|
|
} |
|
982
|
|
|
|
|
983
|
|
|
/** |
|
984
|
|
|
* #### PDFA |
|
985
|
|
|
* |
|
986
|
|
|
* Specify the -dPDFA option to specify PDF/A-1, -dPDFA=2 for PDF/A-2 or -dPDFA=3 for PDF/A-3. |
|
987
|
|
|
* |
|
988
|
|
|
* @param int $version |
|
989
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
990
|
|
|
*/ |
|
991
|
|
|
public function pdfA(int $version): self |
|
992
|
|
|
{ |
|
993
|
|
|
$this->pdfA = $version; |
|
994
|
|
|
|
|
995
|
|
|
return $this; |
|
996
|
|
|
} |
|
997
|
|
|
|
|
998
|
|
|
/** |
|
999
|
|
|
* #### PDFACompatibilityPolicy |
|
1000
|
|
|
* |
|
1001
|
|
|
* When an operation (e.g. pdfmark) is encountered which cannot be emitted in a |
|
1002
|
|
|
* PDF/A compliant file, this policy is consulted, there are currently three possible values: |
|
1003
|
|
|
* - 0 - (default) Include the feature or operation in the output file, the file will not be PDF/A compliant. Because the document Catalog is emitted before this is encountered, the file will still contain PDF/A metadata but will not be compliant. A warning will be emitted in this case. |
|
1004
|
|
|
* - 1 - The feature or operation is ignored, the resulting PDF file will be PDF/A compliant. A warning will be emitted for every elided feature. |
|
1005
|
|
|
* - 2 - Processing of the file is aborted with an error, the exact error may vary depending on the nature of the PDF/A incompatibility. |
|
1006
|
|
|
* |
|
1007
|
|
|
* @param int $policy |
|
1008
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
1009
|
|
|
*/ |
|
1010
|
|
|
public function pdfACompatibilityPolicy(int $policy): self |
|
1011
|
|
|
{ |
|
1012
|
|
|
$this->pdfACompatibilityPolicy = $policy; |
|
1013
|
|
|
|
|
1014
|
|
|
return $this; |
|
1015
|
|
|
} |
|
1016
|
|
|
|
|
1017
|
|
|
/** |
|
1018
|
|
|
* #### PDFX |
|
1019
|
|
|
* |
|
1020
|
|
|
* Specify the -dPDFX option. |
|
1021
|
|
|
* It provides the document conformity and forces -dCompatibilityLevel=1.3. |
|
1022
|
|
|
* |
|
1023
|
|
|
* @param bool $status |
|
1024
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
1025
|
|
|
*/ |
|
1026
|
|
|
public function pdfX(bool $status = true): self |
|
1027
|
|
|
{ |
|
1028
|
|
|
$this->pdfX = $status; |
|
1029
|
|
|
|
|
1030
|
|
|
return $this; |
|
1031
|
|
|
} |
|
1032
|
|
|
|
|
1033
|
|
|
/** |
|
1034
|
|
|
* #### PreserveEPSInfo |
|
1035
|
|
|
* |
|
1036
|
|
|
* If true, and ParseDSCComments is true, Distiller attempts to preserve the |
|
1037
|
|
|
* encapsulated PostScript (EPS) information in the PostScript file as properties of |
|
1038
|
|
|
* the resulting PDF file. |
|
1039
|
|
|
* |
|
1040
|
|
|
* @param bool $status |
|
1041
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
1042
|
|
|
*/ |
|
1043
|
|
|
public function preserveEpsInfo(bool $status = true): self |
|
1044
|
|
|
{ |
|
1045
|
|
|
$this->preserveEpsInfo = $status; |
|
1046
|
|
|
|
|
1047
|
|
|
return $this; |
|
1048
|
|
|
} |
|
1049
|
|
|
|
|
1050
|
|
|
/** |
|
1051
|
|
|
* #### PreserveHalftoneInfo |
|
1052
|
|
|
* |
|
1053
|
|
|
* If true, Distiller passes halftone screen information (frequency, angle, and spot |
|
1054
|
|
|
* function) into the PDF file. |
|
1055
|
|
|
* If false, halftone information is not passed in. |
|
1056
|
|
|
* |
|
1057
|
|
|
* @param bool $status |
|
1058
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
1059
|
|
|
*/ |
|
1060
|
|
|
public function preserveHalftoneInfo(bool $status = true): self |
|
1061
|
|
|
{ |
|
1062
|
|
|
$this->preserveHalftoneInfo = $status; |
|
1063
|
|
|
|
|
1064
|
|
|
return $this; |
|
1065
|
|
|
} |
|
1066
|
|
|
|
|
1067
|
|
|
/** |
|
1068
|
|
|
* #### PreserveMarkedContent |
|
1069
|
|
|
* |
|
1070
|
|
|
* We now attempt to preserve marked content from input PDF files through to the output |
|
1071
|
|
|
* PDF file (note, not in output PostScript!) This does not include marked content relating |
|
1072
|
|
|
* to optional content, because currently we do not preserve optional content, it is |
|
1073
|
|
|
* instead applied by the interpreter. |
|
1074
|
|
|
* |
|
1075
|
|
|
* This control also requires the PDF interpreter to pass the marked content to the |
|
1076
|
|
|
* pdfwrite device, this is only done with the new (C-based) PDF interpreter. The |
|
1077
|
|
|
* old (PostScript-based) interpreter does not support this feature and will not pass |
|
1078
|
|
|
* marked content to the pdfwrite device. |
|
1079
|
|
|
* |
|
1080
|
|
|
* @param bool $status |
|
1081
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
1082
|
|
|
*/ |
|
1083
|
|
|
public function preserveMarkedContent(bool $status = true): self |
|
1084
|
|
|
{ |
|
1085
|
|
|
$this->preserveMarkedContent = $status; |
|
1086
|
|
|
|
|
1087
|
|
|
return $this; |
|
1088
|
|
|
} |
|
1089
|
|
|
|
|
1090
|
|
|
/** |
|
1091
|
|
|
* #### PreserveOPIComments |
|
1092
|
|
|
* |
|
1093
|
|
|
* If true, Distiller places the page contents within a set of Open Prepress Interface |
|
1094
|
|
|
* (OPI) comments in a Form XObject dictionary and preserves the OPI comment information |
|
1095
|
|
|
* in an OPI dictionary attached to the Form. Page contents data within a set of OPI |
|
1096
|
|
|
* comments may include proxy images, high-resolution images, or nothing. |
|
1097
|
|
|
* |
|
1098
|
|
|
* If PreserveOPIComments is false, Distiller ignores OPI comments and their page |
|
1099
|
|
|
* contents. Setting PreserveOPIComments to false results in slightly simpler and smaller |
|
1100
|
|
|
* PDF files. Doing so is acceptable when use of an OPI server is not anticipated. |
|
1101
|
|
|
* |
|
1102
|
|
|
* Distiller ignores PreserveOPIComments if ParseDSCComments is false. |
|
1103
|
|
|
* |
|
1104
|
|
|
* @param bool $status |
|
1105
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
1106
|
|
|
*/ |
|
1107
|
|
|
public function preserveOpiComments(bool $status = true): self |
|
1108
|
|
|
{ |
|
1109
|
|
|
$this->preserveOpiComments = $status; |
|
1110
|
|
|
|
|
1111
|
|
|
return $this; |
|
1112
|
|
|
} |
|
1113
|
|
|
|
|
1114
|
|
|
/** |
|
1115
|
|
|
* #### PreserveOverprintSettings |
|
1116
|
|
|
* |
|
1117
|
|
|
* If true, Distiller passes the value of the setoverprint operator through to the PDF file. |
|
1118
|
|
|
* If false, overprint is ignored (the information is not passed). |
|
1119
|
|
|
* |
|
1120
|
|
|
* @param bool $status |
|
1121
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
1122
|
|
|
*/ |
|
1123
|
|
|
public function preserveOverprintSettings(bool $status = true): self |
|
1124
|
|
|
{ |
|
1125
|
|
|
$this->preserveOverprintSettings = $status; |
|
1126
|
|
|
|
|
1127
|
|
|
return $this; |
|
1128
|
|
|
} |
|
1129
|
|
|
|
|
1130
|
|
|
/** |
|
1131
|
|
|
* #### ProcessColorModel |
|
1132
|
|
|
* |
|
1133
|
|
|
* A symbol taken from /DeviceGray, /DeviceRGB or /DeviceCMYK which can be used to |
|
1134
|
|
|
* select 1, 3 or 4 colors respectively. |
|
1135
|
|
|
* |
|
1136
|
|
|
* Note that this parameter takes precedence over Colors, and that both affect the |
|
1137
|
|
|
* same variable of the driver. |
|
1138
|
|
|
* |
|
1139
|
|
|
* @param ProcessColorModel $model |
|
1140
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
1141
|
|
|
*/ |
|
1142
|
|
|
public function processColorModel(ProcessColorModel $model): self |
|
1143
|
|
|
{ |
|
1144
|
|
|
$this->processColorModel = $model; |
|
1145
|
|
|
|
|
1146
|
|
|
return $this; |
|
1147
|
|
|
} |
|
1148
|
|
|
|
|
1149
|
|
|
/** |
|
1150
|
|
|
* #### PDFSETTINGS |
|
1151
|
|
|
* |
|
1152
|
|
|
* Presets the “distiller parameters” to one of the following predefined settings: |
|
1153
|
|
|
* - /screen selects low-resolution output similar to the Acrobat Distiller (up to version X) “Screen Optimized” setting. |
|
1154
|
|
|
* - /ebook selects medium-resolution output similar to the Acrobat Distiller (up to version X) “eBook” setting. |
|
1155
|
|
|
* - /printer selects output similar to the Acrobat Distiller “Print Optimized” (up to version X) setting. |
|
1156
|
|
|
* - /prepress selects output similar to Acrobat Distiller “Prepress Optimized” (up to version X) setting. |
|
1157
|
|
|
* - /default selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file. |
|
1158
|
|
|
* |
|
1159
|
|
|
* Please be aware that the /prepress setting does not indicate the highest quality |
|
1160
|
|
|
* conversion. Using any of these presets will involve altering the input, and as |
|
1161
|
|
|
* such may result in a PDF of poorer quality (compared to the input) than simply using |
|
1162
|
|
|
* the defaults. The ‘best’ quality (where best means closest to the original |
|
1163
|
|
|
* input) is obtained by not setting this parameter at all (or by using /default). |
|
1164
|
|
|
* |
|
1165
|
|
|
* The PDFSETTINGS presets should only be used if you are sure you understand that |
|
1166
|
|
|
* the output will be altered in a variety of ways from the input. It is usually |
|
1167
|
|
|
* better to adjust the controls individually if you have a genuine requirement to |
|
1168
|
|
|
* produce, for example, a PDF file where the images are reduced in resolution. |
|
1169
|
|
|
* |
|
1170
|
|
|
* @param PdfSettings $settings |
|
1171
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
1172
|
|
|
*/ |
|
1173
|
|
|
public function settings(PdfSettings $settings): self |
|
1174
|
|
|
{ |
|
1175
|
|
|
$this->pdfSettings = $settings; |
|
1176
|
|
|
|
|
1177
|
|
|
return $this; |
|
1178
|
|
|
} |
|
1179
|
|
|
|
|
1180
|
|
|
/** |
|
1181
|
|
|
* #### SubsetFonts |
|
1182
|
|
|
* |
|
1183
|
|
|
* If true, font subsetting is enabled. |
|
1184
|
|
|
* If false, subsetting is not enabled. Font subsetting embeds only those glyphs that |
|
1185
|
|
|
* are used in a document, instead of the entire font. This reduces the size of a |
|
1186
|
|
|
* PDF file that contains embedded fonts. If font subsetting is enabled, the application |
|
1187
|
|
|
* determines whether to embed the entire font or a subset by the number of glyphs in |
|
1188
|
|
|
* the font that are used (including component glyphs referenced by ‘seac’ [Type 1] |
|
1189
|
|
|
* glyphs), and the value of MaxSubsetPct. |
|
1190
|
|
|
* |
|
1191
|
|
|
* @param bool $status |
|
1192
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
1193
|
|
|
*/ |
|
1194
|
|
|
public function subsetFonts(bool $status = true): self |
|
1195
|
|
|
{ |
|
1196
|
|
|
$this->subsetFonts = $status; |
|
1197
|
|
|
|
|
1198
|
|
|
return $this; |
|
1199
|
|
|
} |
|
1200
|
|
|
|
|
1201
|
|
|
/** |
|
1202
|
|
|
* #### UCRandBGInfo |
|
1203
|
|
|
* |
|
1204
|
|
|
* @param UCRandBGInfo $info |
|
1205
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
1206
|
|
|
*/ |
|
1207
|
|
|
public function ucRandBbInfo(UCRandBGInfo $info): self |
|
1208
|
|
|
{ |
|
1209
|
|
|
$this->ucRandBbInfo = $info; |
|
1210
|
|
|
|
|
1211
|
|
|
return $this; |
|
1212
|
|
|
} |
|
1213
|
|
|
|
|
1214
|
|
|
/** |
|
1215
|
|
|
* #### UseFlateCompression |
|
1216
|
|
|
* |
|
1217
|
|
|
* Because the LZW compression scheme was covered by patents at the time this device |
|
1218
|
|
|
* was created, pdfwrite does not actually use LZW compression: all requests for LZW |
|
1219
|
|
|
* compression are ignored. UseFlateCompression is treated as always on, but the |
|
1220
|
|
|
* switch CompressPages can be set too false to turn off page level stream compression. |
|
1221
|
|
|
* Now that the patent has expired, we could change this should it become worthwhile. |
|
1222
|
|
|
* |
|
1223
|
|
|
* @param bool $status |
|
1224
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
1225
|
|
|
*/ |
|
1226
|
|
|
public function useFlateCompression(bool $status = true): self |
|
1227
|
|
|
{ |
|
1228
|
|
|
$this->useFlateCompression = $status; |
|
1229
|
|
|
|
|
1230
|
|
|
return $this; |
|
1231
|
|
|
} |
|
1232
|
|
|
|
|
1233
|
|
|
/** |
|
1234
|
|
|
* @param string[] $options |
|
1235
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
1236
|
|
|
*/ |
|
1237
|
|
|
public function setExtraOptions(array $options): self |
|
1238
|
|
|
{ |
|
1239
|
|
|
$this->extraOptions = $options; |
|
1240
|
|
|
|
|
1241
|
|
|
return $this; |
|
1242
|
|
|
} |
|
1243
|
|
|
|
|
1244
|
|
|
/** |
|
1245
|
|
|
* Set timeout in seconds |
|
1246
|
|
|
* |
|
1247
|
|
|
* @param int $seconds |
|
1248
|
|
|
* @return PdfOptimizerProperties|PdfOptimizer |
|
1249
|
|
|
*/ |
|
1250
|
|
|
public function setTimeout(int $seconds): self |
|
1251
|
|
|
{ |
|
1252
|
|
|
$this->timeout = $seconds; |
|
1253
|
|
|
|
|
1254
|
|
|
return $this; |
|
1255
|
|
|
} |
|
1256
|
|
|
} |
|
1257
|
|
|
|