PDFExtGState.java
20.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.pdftoolkit.core.cos.CosArray
* com.adobe.internal.pdftoolkit.core.cos.CosDictionary
* com.adobe.internal.pdftoolkit.core.cos.CosName
* com.adobe.internal.pdftoolkit.core.cos.CosObject
* com.adobe.internal.pdftoolkit.core.exceptions.PDFCosParseException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException
* com.adobe.internal.pdftoolkit.core.types.ASName
*/
package com.adobe.internal.pdftoolkit.pdf.graphics;
import com.adobe.internal.pdftoolkit.core.cos.CosArray;
import com.adobe.internal.pdftoolkit.core.cos.CosDictionary;
import com.adobe.internal.pdftoolkit.core.cos.CosName;
import com.adobe.internal.pdftoolkit.core.cos.CosObject;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFCosParseException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException;
import com.adobe.internal.pdftoolkit.core.types.ASName;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosDictionary;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosObject;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosUtils;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import com.adobe.internal.pdftoolkit.pdf.document.PDFStream;
import com.adobe.internal.pdftoolkit.pdf.document.PDFValueContainer;
import com.adobe.internal.pdftoolkit.pdf.graphics.PDFFunction;
import com.adobe.internal.pdftoolkit.pdf.graphics.PDFFunctionFactory;
import com.adobe.internal.pdftoolkit.pdf.graphics.colorspaces.PDFRenderingIntent;
import com.adobe.internal.pdftoolkit.pdf.graphics.font.PDFFont;
import com.adobe.internal.pdftoolkit.pdf.graphics.font.PDFFontFactory;
import com.adobe.internal.pdftoolkit.pdf.rendering.PDFHalfToneFactory;
import com.adobe.internal.pdftoolkit.pdf.rendering.PDFHalftone;
import com.adobe.internal.pdftoolkit.pdf.transparency.PDFSoftMask;
import java.util.ArrayList;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class PDFExtGState
extends PDFCosDictionary {
private PDFExtGState(CosObject cosObject) throws PDFInvalidDocumentException {
super(cosObject);
}
public static PDFExtGState getInstance(CosObject cosObject) throws PDFInvalidDocumentException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFExtGState pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFExtGState.class);
if (pdfObject == null) {
pdfObject = new PDFExtGState(cosObject);
}
return pdfObject;
}
public static PDFExtGState newInstance(PDFDocument pdfDocument) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosDictionary cosDict = PDFCosObject.newCosDictionary(pdfDocument);
cosDict.put(ASName.k_Type, ASName.k_ExtGState);
return PDFExtGState.getInstance((CosObject)cosDict);
}
public boolean hasLineWidth() {
return this.getCosDictionary().containsKey((Object)ASName.k_LW);
}
public double getLineWidth() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getCosDictionary().getDouble(ASName.k_LW);
}
public boolean hasLineCap() {
return this.getCosDictionary().containsKey((Object)ASName.k_LC);
}
public int getLineCap() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getCosDictionary().getInt(ASName.k_LC);
}
public boolean hasLineJoin() {
return this.getCosDictionary().containsKey((Object)ASName.k_LJ);
}
public int getLineJoin() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getCosDictionary().getInt(ASName.k_LJ);
}
public boolean hasMiterLimit() {
return this.getCosDictionary().containsKey((Object)ASName.k_ML);
}
public double getMiterLimit() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getCosDictionary().getDouble(ASName.k_ML);
}
public boolean hasDashPattern() {
return this.getCosDictionary().containsKey((Object)ASName.k_D);
}
public CosArray getDashPattern() throws PDFCosParseException, PDFIOException, PDFSecurityException {
return this.getCosDictionary().getCosArray(ASName.k_D);
}
public boolean hasRenderingIntent() {
return this.getCosDictionary().containsKey((Object)ASName.k_RI);
}
public ASName getRenderingIntent() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getCosDictionary().getName(ASName.k_RI);
}
public void setRenderingIntent(PDFRenderingIntent intent) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryNameValue(ASName.k_RI, intent.getValue());
}
public boolean hasOverprintStroke() {
return this.getCosDictionary().containsKey((Object)ASName.k_OP);
}
public boolean getOverprintStroke() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getCosDictionary().getBoolean(ASName.k_OP);
}
public boolean hasOverprintFill() {
return this.getCosDictionary().containsKey((Object)ASName.k_op);
}
public boolean getOverprintFill() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getCosDictionary().getBoolean(ASName.k_op);
}
public boolean hasOverprintMode() {
return this.getCosDictionary().containsKey((Object)ASName.k_OPM);
}
public int getOverprintMode() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getCosDictionary().getInt(ASName.k_OPM);
}
public boolean hasFont() {
return this.getCosDictionary().containsKey((Object)ASName.k_Font);
}
public PDFFontContainer getFontContainer() throws PDFIOException, PDFSecurityException, PDFInvalidDocumentException {
CosArray cosArray = this.getCosDictionary().getCosArray(ASName.k_Font);
return new PDFFontContainer((PDFFont)PDFFontFactory.getInstance(cosArray.get(0)), cosArray.get(1).intValue());
}
public void setFontContainer(PDFFontContainer fontContainer) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
ArrayList<Object> list = new ArrayList<Object>();
list.add(fontContainer.getFont());
list.add(fontContainer.getSize());
this.setDictionaryArrayValue(ASName.k_Font, PDFCosUtils.newCosArray(this.getPDFDocument(), list));
}
public boolean hasBGFunction() {
return this.getCosDictionary().containsKey((Object)ASName.k_BG) || this.getCosDictionary().containsKey((Object)ASName.k_BG2);
}
public PDFValueContainer<PDFValueContainer.Type, Object> getBGFunction() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosObject cosObj;
CosObject cosObject = cosObj = this.getDictionaryValue(ASName.k_BG2) == null ? this.getDictionaryValue(ASName.k_BG) : null;
if (cosObj instanceof CosDictionary) {
return new PDFValueContainer<PDFValueContainer.Type, Object>(PDFValueContainer.Type.Function, PDFFunctionFactory.getInstance(cosObj));
}
if (cosObj instanceof CosName) {
return new PDFValueContainer<PDFValueContainer.Type, ASName>(PDFValueContainer.Type.Name, cosObj.nameValue());
}
return null;
}
public boolean isBGDefault() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.hasBGFunction()) {
return true;
}
CosObject cosObj = this.getDictionaryValue(ASName.k_BG2);
if (cosObj != null ? !(cosObj instanceof CosName) || cosObj.nameValue() != ASName.k_Default : this.getCosDictionary().containsKey((Object)ASName.k_BG)) {
return false;
}
return true;
}
public boolean hasUCRFunction() {
return this.getCosDictionary().containsKey((Object)ASName.k_UCR) || this.getCosDictionary().containsKey((Object)ASName.k_UCR2);
}
public PDFValueContainer<PDFValueContainer.Type, Object> getUCRFunction() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosObject ucr2 = this.getDictionaryValue(ASName.k_UCR2);
if (ucr2 instanceof CosDictionary) {
return new PDFValueContainer<PDFValueContainer.Type, Object>(PDFValueContainer.Type.Function, PDFFunctionFactory.getInstance(ucr2));
}
if (ucr2 instanceof CosName) {
return new PDFValueContainer<PDFValueContainer.Type, ASName>(PDFValueContainer.Type.Name, ucr2.nameValue());
}
CosObject ucr = this.getDictionaryValue(ASName.k_UCR);
if (ucr instanceof CosDictionary) {
return new PDFValueContainer<PDFValueContainer.Type, Object>(PDFValueContainer.Type.Function, PDFFunctionFactory.getInstance(ucr));
}
if (ucr instanceof CosName) {
return new PDFValueContainer<PDFValueContainer.Type, ASName>(PDFValueContainer.Type.Name, ucr.nameValue());
}
return null;
}
public boolean isUCRDefault() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.hasUCRFunction()) {
return true;
}
CosObject cosObj = this.getDictionaryValue(ASName.k_UCR2);
if (cosObj != null ? !(cosObj instanceof CosName) || cosObj.nameValue() != ASName.k_Default : this.getCosDictionary().containsKey((Object)ASName.k_UCR)) {
return false;
}
return true;
}
public boolean hasTransferFunction() {
return this.getCosDictionary().containsKey((Object)ASName.k_TR) || this.getCosDictionary().containsKey((Object)ASName.k_TR2);
}
public boolean isTRIdentity() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.hasTransferFunction()) {
return true;
}
CosObject cosObjTR2 = this.getDictionaryValue(ASName.k_TR2);
CosObject cosObjTR = this.getDictionaryValue(ASName.k_TR);
if (cosObjTR2 != null ? !(cosObjTR2 instanceof CosName) || cosObjTR2.nameValue() != ASName.k_Identity : cosObjTR != null && (!(cosObjTR instanceof CosName) || cosObjTR.nameValue() != ASName.k_Identity)) {
return false;
}
return true;
}
public PDFValueContainer<PDFValueContainer.Type, Object> getTransferFunction() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosObject cosObj;
CosObject cosObject = cosObj = this.getCosDictionary().get(ASName.k_TR2) == null ? this.getCosDictionary().get(ASName.k_TR) : null;
if (cosObj != null) {
int type = cosObj.getType();
if (type == 3) {
return new PDFValueContainer<PDFValueContainer.Type, ASName>(PDFValueContainer.Type.Name, cosObj.nameValue());
}
if (type == 6) {
return new PDFValueContainer<PDFValueContainer.Type, Object>(PDFValueContainer.Type.Function, PDFFunctionFactory.getInstance(cosObj));
}
if (type == 5) {
CosArray array = (CosArray)cosObj;
int size = array.size();
PDFFunction[] functions = new PDFFunction[size];
for (int i = 0; i < size; ++i) {
functions[i] = PDFFunctionFactory.getInstance(array.get(i));
}
return new PDFValueContainer<PDFValueContainer.Type, PDFFunction[]>(PDFValueContainer.Type.FunctionArray, functions);
}
}
return null;
}
public boolean hasHalftone() {
return this.getCosDictionary().containsKey((Object)ASName.k_HT);
}
public PDFHalftone getHT() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return PDFHalfToneFactory.getInstance(this.getDictionaryValue(ASName.k_HT));
}
public boolean isHalftoneDefault() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.hasHalftone()) {
return true;
}
CosObject cosObj = this.getDictionaryValue(ASName.k_HT);
if (!(cosObj instanceof CosName) || cosObj.nameValue() != ASName.k_Default) {
return false;
}
return true;
}
public boolean hasFlatness() {
return this.getCosDictionary().containsKey((Object)ASName.k_FL);
}
public double getFlatness() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getCosDictionary().getDouble(ASName.k_FL);
}
public boolean hasSmoothness() {
return this.getCosDictionary().containsKey((Object)ASName.k_SM);
}
public double getSmoothness() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getCosDictionary().getDouble(ASName.k_SM);
}
public boolean haStrokeAdjustment() {
return this.getCosDictionary().containsKey((Object)ASName.k_SA);
}
public boolean getStrokeAdjustment() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getCosDictionary().getBoolean(ASName.k_SA);
}
public boolean hasBlendMode() {
return this.getCosDictionary().containsKey((Object)ASName.k_BM);
}
public ASName[] getBlendMode() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosObject cosObj = this.getCosDictionary().get(ASName.k_BM);
ASName[] asNames = null;
if (cosObj instanceof CosArray) {
CosArray array = (CosArray)cosObj;
int size = array.size();
asNames = new ASName[size];
for (int i = 0; i < size; ++i) {
asNames[i] = array.getName(i);
}
} else if (cosObj instanceof CosName) {
asNames = new ASName[]{cosObj.nameValue()};
}
return asNames;
}
public void setBlendMode(ASName blendMode) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryNameValue(ASName.k_BM, blendMode);
}
public boolean isBMNormal() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.hasBlendMode()) {
return true;
}
CosObject cosObj = this.getDictionaryValue(ASName.k_BM);
if (!(cosObj instanceof CosName) || cosObj.nameValue() != ASName.k_Normal) {
return false;
}
return true;
}
public boolean hasSoftMask() {
return this.getCosDictionary().containsKey((Object)ASName.k_SMask);
}
public Boolean isSoftMaskDictionary() throws PDFIOException, PDFSecurityException, PDFInvalidDocumentException {
CosObject cosObj = this.getCosDictionary().get(ASName.k_SMask);
if (cosObj != null) {
if (cosObj instanceof CosDictionary) {
return true;
}
if (cosObj instanceof CosName) {
return false;
}
throw new PDFInvalidDocumentException("Soft mask should either be a name or dictionary.");
}
return null;
}
public PDFValueContainer<PDFValueContainer.Type, Object> getSoftMask() throws PDFIOException, PDFSecurityException, PDFInvalidDocumentException {
CosObject cosObj = this.getCosDictionary().get(ASName.k_SMask);
if (cosObj != null) {
int type = cosObj.getType();
if (type == 6) {
return new PDFValueContainer<PDFValueContainer.Type, Object>(PDFValueContainer.Type.SoftMask, PDFSoftMask.getInstance(cosObj));
}
if (type == 3) {
return new PDFValueContainer<PDFValueContainer.Type, ASName>(PDFValueContainer.Type.Name, cosObj.nameValue());
}
}
return null;
}
public void setSoftMask(PDFSoftMask softMask) throws PDFIOException, PDFSecurityException, PDFInvalidDocumentException {
this.setDictionaryValue(ASName.k_SMask, softMask);
}
public void setSoftMask(ASName softMask) throws PDFIOException, PDFSecurityException, PDFInvalidDocumentException {
this.setDictionaryNameValue(ASName.k_SMask, softMask);
}
public boolean isSoftMaskNone() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.hasSoftMask()) {
return true;
}
CosObject cosObj = this.getDictionaryValue(ASName.k_SMask);
if (!(cosObj instanceof CosName) || cosObj.nameValue() != ASName.k_None) {
return false;
}
return true;
}
public boolean hasOpacityStroke() {
return this.getCosDictionary().containsKey((Object)ASName.k_CA);
}
public double getOpacityStroke() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getCosDictionary().getDouble(ASName.k_CA);
}
public void setOpacityStroke(double opacity) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryDoubleValue(ASName.k_CA, opacity);
}
public boolean hasOpacityFill() {
return this.getCosDictionary().containsKey((Object)ASName.k_ca);
}
public double getOpacityFill() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getCosDictionary().getDouble(ASName.k_ca);
}
public void setOpacityFill(double opacity) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryDoubleValue(ASName.k_ca, opacity);
}
public boolean hasAlphaSource() {
return this.getCosDictionary().containsKey((Object)ASName.k_AIS);
}
public boolean getAlphaSource() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getCosDictionary().getBoolean(ASName.k_AIS);
}
public boolean hasTextKnockout() {
return this.getCosDictionary().containsKey((Object)ASName.k_TK);
}
public boolean getTextKnockout() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getCosDictionary().getBoolean(ASName.k_TK);
}
public PDFHalftone getHalfTone() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return PDFHalfToneFactory.getInstance(this.getDictionaryCosObjectValue(ASName.k_HT));
}
public void setHT(PDFHalftone value) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryValue(ASName.k_HT, value);
}
public ASName getHTAsName() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryNameValue(ASName.k_HT);
}
public void setHT(ASName value) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryNameValue(ASName.k_HT, value);
}
public PDFStream getHTAsStream() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosObject cosObject = this.getDictionaryValue(ASName.k_HT);
return PDFStream.getInstance(cosObject);
}
public void setHT(PDFStream value) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryValue(ASName.k_HT, value);
}
public boolean hasHT() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(ASName.k_HT);
}
public ASName getUseBlackPTComp() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
ASName useBlackPTComp = this.getCosDictionary().getName(ASName.k_UseBlackPTComp);
if (useBlackPTComp == null) {
return ASName.k_Default;
}
return useBlackPTComp;
}
public void setUseBlackPTComp(ASName useBlackPTComp) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (useBlackPTComp == ASName.k_ON || useBlackPTComp == ASName.k_OFF || useBlackPTComp == ASName.k_Default) {
this.setDictionaryNameValue(ASName.k_UseBlackPTComp, useBlackPTComp);
}
}
public static class PDFFontContainer {
PDFFont font;
Integer size;
public PDFFontContainer(PDFFont font, Integer size) {
this.font = font;
this.size = size;
}
public PDFFont getFont() {
return this.font;
}
public Integer getSize() {
return this.size;
}
}
}