PDFDefaultAppearanceWrapper.java
26.2 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
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.io.stream.InputByteStream
* com.adobe.internal.pdftoolkit.core.cos.CosDictionary
* 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.exceptions.PDFUnableToCompleteOperationException
* com.adobe.internal.pdftoolkit.core.types.ASName
* com.adobe.internal.pdftoolkit.core.types.ASNumber
*/
package com.adobe.internal.pdftoolkit.pdf.interactive.forms.impl;
import com.adobe.internal.io.stream.InputByteStream;
import com.adobe.internal.pdftoolkit.core.cos.CosDictionary;
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.exceptions.PDFUnableToCompleteOperationException;
import com.adobe.internal.pdftoolkit.core.types.ASName;
import com.adobe.internal.pdftoolkit.core.types.ASNumber;
import com.adobe.internal.pdftoolkit.pdf.content.Content;
import com.adobe.internal.pdftoolkit.pdf.content.ContentReader;
import com.adobe.internal.pdftoolkit.pdf.content.Instruction;
import com.adobe.internal.pdftoolkit.pdf.content.InstructionFactory;
import com.adobe.internal.pdftoolkit.pdf.content.NoopOperatorHandler;
import com.adobe.internal.pdftoolkit.pdf.content.OperandStack;
import com.adobe.internal.pdftoolkit.pdf.content.processor.ConditionalContentStreamProcessor;
import com.adobe.internal.pdftoolkit.pdf.content.processor.IConditionalOperatorHandler;
import com.adobe.internal.pdftoolkit.pdf.contentmodify.ContentWriter;
import com.adobe.internal.pdftoolkit.pdf.contentmodify.ModifiableContent;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import com.adobe.internal.pdftoolkit.pdf.document.PDFResources;
import com.adobe.internal.pdftoolkit.pdf.graphics.font.PDFFont;
import com.adobe.internal.pdftoolkit.pdf.graphics.font.PDFFontMap;
import com.adobe.internal.pdftoolkit.pdf.graphics.font.impl.StandardFontUtils;
import com.adobe.internal.pdftoolkit.pdf.interactive.forms.PDFDefaultAppearance;
import com.adobe.internal.pdftoolkit.pdf.interactive.forms.PDFInteractiveForm;
import java.io.IOException;
import java.util.List;
public class PDFDefaultAppearanceWrapper {
private PDFDefaultAppearance defaultAp;
private String fontName;
private String baseFontName;
private double fontSize;
private double[] fontColor;
private double[] fillColor;
private double[] strokeColor;
private ASName colorSpace;
private ASName[] allColorTypes = new ASName[]{ASName.k_g, ASName.k_G, ASName.k_rg, ASName.k_RG, ASName.k_k, ASName.k_K};
private boolean isBaseFontNameInitialized = false;
private Double charSpacing;
private Double wordSpacing;
private Double scale;
private Double rise;
private Double leading;
public PDFDefaultAppearanceWrapper(PDFDefaultAppearance defAp) throws PDFInvalidDocumentException, PDFSecurityException, PDFIOException, PDFUnableToCompleteOperationException {
this.defaultAp = defAp;
this.init();
}
public String getFontName() throws PDFSecurityException, PDFIOException, PDFInvalidDocumentException, PDFUnableToCompleteOperationException {
return this.fontName;
}
public String getBaseFontName() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, PDFUnableToCompleteOperationException {
if (!this.isBaseFontNameInitialized) {
this.updateBaseFontName();
this.isBaseFontNameInitialized = true;
}
return this.baseFontName;
}
public PDFDefaultAppearance setBaseFontName(String newBaseFontName) throws PDFSecurityException, PDFIOException, PDFInvalidDocumentException, PDFUnableToCompleteOperationException {
if (newBaseFontName.equals(this.baseFontName)) {
return this.defaultAp;
}
this.baseFontName = newBaseFontName;
this.updateFontName();
return this.updateValue(new ASName[]{ASName.k_Tf});
}
public double getFontSize() throws PDFSecurityException, PDFIOException, PDFInvalidDocumentException, PDFUnableToCompleteOperationException {
return this.fontSize;
}
public PDFDefaultAppearance setFontSize(double newFontSize) throws PDFSecurityException, PDFIOException, PDFInvalidDocumentException, PDFUnableToCompleteOperationException {
if (newFontSize == this.fontSize) {
return this.defaultAp;
}
this.fontSize = newFontSize;
return this.updateValue(new ASName[]{ASName.k_Tf});
}
public double[] getFontColor() throws PDFSecurityException, PDFIOException, PDFInvalidDocumentException, PDFUnableToCompleteOperationException {
return this.fontColor;
}
public PDFDefaultAppearance setFontColor(ASName colorSpace, double[] newFontColor) throws PDFSecurityException, PDFIOException, PDFInvalidDocumentException, PDFUnableToCompleteOperationException {
if (newFontColor == this.fontColor) {
return this.defaultAp;
}
this.fontColor = newFontColor;
this.colorSpace = this.getPDFColorSpace(colorSpace, this.fontColor);
return this.updateValue(this.allColorTypes);
}
public String getColorSpace() throws PDFUnableToCompleteOperationException, PDFSecurityException, PDFIOException, PDFInvalidDocumentException {
return this.colorSpace.asString();
}
private void init() throws PDFSecurityException, PDFIOException, PDFInvalidDocumentException, PDFUnableToCompleteOperationException {
NoopOperatorHandler operatorHandler = new NoopOperatorHandler(){
public void Tf(ASName fName, double fSize, Instruction instruction) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFDefaultAppearanceWrapper.this.fontSize = fSize;
PDFDefaultAppearanceWrapper.this.fontName = fName.asString();
}
public void G(float gray, Instruction instruction) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (PDFDefaultAppearanceWrapper.this.fontColor == null) {
PDFDefaultAppearanceWrapper.this.colorSpace = ASName.k_G;
}
this.handleGOperators(gray, PDFDefaultAppearanceWrapper.this.fontColor == null, false);
}
public void g(float gray, Instruction instruction) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (PDFDefaultAppearanceWrapper.this.fontColor == null) {
PDFDefaultAppearanceWrapper.this.colorSpace = ASName.k_g;
}
this.handleGOperators(gray, PDFDefaultAppearanceWrapper.this.fontColor == null, true);
}
public void RG(float r, float g, float b, Instruction instruction) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (PDFDefaultAppearanceWrapper.this.fontColor == null) {
PDFDefaultAppearanceWrapper.this.colorSpace = ASName.k_RG;
}
this.handleRGOperators(r, g, b, PDFDefaultAppearanceWrapper.this.fontColor == null, false);
}
public void rg(float r, float g, float b, Instruction instruction) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (PDFDefaultAppearanceWrapper.this.fontColor == null) {
PDFDefaultAppearanceWrapper.this.colorSpace = ASName.k_rg;
}
this.handleRGOperators(r, g, b, PDFDefaultAppearanceWrapper.this.fontColor == null, true);
}
public void k(float c, float m, float y, float k, Instruction instruction) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (PDFDefaultAppearanceWrapper.this.fontColor == null) {
PDFDefaultAppearanceWrapper.this.colorSpace = ASName.k_k;
}
this.handleKOperators(c, m, y, k, PDFDefaultAppearanceWrapper.this.fontColor == null, true);
}
public void K(float c, float m, float y, float k, Instruction instruction) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (PDFDefaultAppearanceWrapper.this.fontColor == null) {
PDFDefaultAppearanceWrapper.this.colorSpace = ASName.k_K;
}
this.handleKOperators(c, m, y, k, PDFDefaultAppearanceWrapper.this.fontColor == null, false);
}
private void handleGOperators(float gray, boolean updateFontColor, boolean fill) {
if (updateFontColor) {
PDFDefaultAppearanceWrapper.this.fontColor = new double[1];
PDFDefaultAppearanceWrapper.access$200((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[0] = gray;
}
if (fill) {
PDFDefaultAppearanceWrapper.this.fillColor = new double[1];
PDFDefaultAppearanceWrapper.access$400((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[0] = gray;
} else {
PDFDefaultAppearanceWrapper.this.strokeColor = new double[1];
PDFDefaultAppearanceWrapper.access$500((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[0] = gray;
}
}
private void handleRGOperators(float r, float g, float b, boolean updateFontColor, boolean fill) {
if (updateFontColor) {
PDFDefaultAppearanceWrapper.this.fontColor = new double[3];
PDFDefaultAppearanceWrapper.access$200((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[2] = b;
PDFDefaultAppearanceWrapper.access$200((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[1] = g;
PDFDefaultAppearanceWrapper.access$200((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[0] = r;
}
if (fill) {
PDFDefaultAppearanceWrapper.this.fillColor = new double[3];
PDFDefaultAppearanceWrapper.access$400((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[2] = b;
PDFDefaultAppearanceWrapper.access$400((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[1] = g;
PDFDefaultAppearanceWrapper.access$400((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[0] = r;
} else {
PDFDefaultAppearanceWrapper.this.strokeColor = new double[3];
PDFDefaultAppearanceWrapper.access$500((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[2] = b;
PDFDefaultAppearanceWrapper.access$500((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[1] = g;
PDFDefaultAppearanceWrapper.access$500((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[0] = r;
}
}
private void handleKOperators(float c, float m, float y, float k, boolean updateFontColor, boolean fill) {
if (updateFontColor) {
PDFDefaultAppearanceWrapper.this.fontColor = new double[4];
PDFDefaultAppearanceWrapper.access$200((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[3] = k;
PDFDefaultAppearanceWrapper.access$200((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[2] = y;
PDFDefaultAppearanceWrapper.access$200((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[1] = m;
PDFDefaultAppearanceWrapper.access$200((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[0] = c;
}
if (fill) {
PDFDefaultAppearanceWrapper.this.fillColor = new double[4];
PDFDefaultAppearanceWrapper.access$400((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[3] = k;
PDFDefaultAppearanceWrapper.access$400((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[2] = y;
PDFDefaultAppearanceWrapper.access$400((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[1] = m;
PDFDefaultAppearanceWrapper.access$400((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[0] = c;
} else {
PDFDefaultAppearanceWrapper.this.strokeColor = new double[4];
PDFDefaultAppearanceWrapper.access$500((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[3] = k;
PDFDefaultAppearanceWrapper.access$500((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[2] = y;
PDFDefaultAppearanceWrapper.access$500((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[1] = m;
PDFDefaultAppearanceWrapper.access$500((PDFDefaultAppearanceWrapper)PDFDefaultAppearanceWrapper.this)[0] = c;
}
}
public void Tc(double cSpacing, Instruction instruction) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFDefaultAppearanceWrapper.this.charSpacing = cSpacing;
}
public void Tw(double wSpacing, Instruction instruction) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFDefaultAppearanceWrapper.this.wordSpacing = wSpacing;
}
public void Tz(double scaling, Instruction instruction) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFDefaultAppearanceWrapper.this.scale = scaling;
}
public void Ts(double textRise, Instruction instruction) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFDefaultAppearanceWrapper.this.rise = textRise;
}
public void TL(double l, Instruction instruction) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFDefaultAppearanceWrapper.this.leading = l;
}
};
ModifiableContent content = ModifiableContent.newInstance(this.defaultAp);
ConditionalContentStreamProcessor processor = new ConditionalContentStreamProcessor(operatorHandler);
processor.process(content);
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
private PDFDefaultAppearance updateValue(ASName[] matchOperators) throws PDFSecurityException, PDFIOException, PDFInvalidDocumentException, PDFUnableToCompleteOperationException {
byte[] bytes;
Content newContent;
PDFDefaultAppearance newDefAp;
ModifiableContent content = ModifiableContent.newInstance(this.defaultAp);
ContentReader reader = null;
ContentWriter writer = ContentWriter.newInstance(this.defaultAp.getPDFDocument());
newContent = null;
try {
reader = ContentReader.newInstance(content);
writer.setInstructionDelimiter(32);
ASName matchOperator = null;
ASName newColorSpace = null;
Instruction instruction = null;
while (reader.hasNext()) {
instruction = reader.next();
ASName operator = instruction.getOperator();
OperandStack operands = instruction.getOperands();
for (int i = 0; i < matchOperators.length; ++i) {
matchOperator = matchOperators[i];
if (!operator.equals((Object)matchOperator)) continue;
if (operator.equals((Object)ASName.k_Tf)) {
operands.pop();
operands.pop();
operands.pushName(ASName.create((String)this.fontName));
operands.pushASNumber(new ASNumber(this.fontSize));
break;
}
if (operator.equals((Object)ASName.k_G) || operator.equals((Object)ASName.k_g)) {
newColorSpace = this.getPDFColorSpace(this.colorSpace, this.fontColor);
if (!newColorSpace.equals((Object)operator)) {
instruction = this.createColorInstruction();
this.colorSpace = newColorSpace;
} else {
operands.pop();
operands.pushASNumber(new ASNumber(this.fontColor[0]));
}
}
if (operator.equals((Object)ASName.k_RG) || operator.equals((Object)ASName.k_rg)) {
newColorSpace = this.getPDFColorSpace(this.colorSpace, this.fontColor);
if (!newColorSpace.equals((Object)operator)) {
instruction = this.createColorInstruction();
this.colorSpace = newColorSpace;
} else {
operands.pop();
operands.pop();
operands.pop();
operands.pushASNumber(new ASNumber(this.fontColor[0]));
operands.pushASNumber(new ASNumber(this.fontColor[1]));
operands.pushASNumber(new ASNumber(this.fontColor[2]));
}
}
if (operator.equals((Object)ASName.k_K) || operator.equals((Object)ASName.k_k)) {
newColorSpace = this.getPDFColorSpace(this.colorSpace, this.fontColor);
if (!newColorSpace.equals((Object)operator)) {
instruction = this.createColorInstruction();
this.colorSpace = newColorSpace;
} else {
operands.pop();
operands.pop();
operands.pop();
operands.pop();
operands.pushASNumber(new ASNumber(this.fontColor[0]));
operands.pushASNumber(new ASNumber(this.fontColor[1]));
operands.pushASNumber(new ASNumber(this.fontColor[2]));
operands.pushASNumber(new ASNumber(this.fontColor[3]));
}
}
if (operator.equals((Object)ASName.k_Tc)) {
operands.pop();
operands.pushASNumber(new ASNumber(this.charSpacing.doubleValue()));
}
if (operator.equals((Object)ASName.k_Tw)) {
operands.pop();
operands.pushASNumber(new ASNumber(this.wordSpacing.doubleValue()));
}
if (operator.equals((Object)ASName.k_Tz)) {
operands.pop();
operands.pushASNumber(new ASNumber(this.scale.doubleValue()));
}
if (operator.equals((Object)ASName.k_Ts)) {
operands.pop();
operands.pushASNumber(new ASNumber(this.rise.doubleValue()));
}
if (!operator.equals((Object)ASName.k_TL)) continue;
operands.pop();
operands.pushASNumber(new ASNumber(this.leading.doubleValue()));
}
writer.write(instruction);
}
}
finally {
try {
if (writer != null) {
newContent = writer.close();
}
}
finally {
try {
if (reader != null) {
reader.close();
}
}
catch (IOException e) {
throw new PDFIOException((Throwable)e);
}
}
}
try {
bytes = this.getBytes(newContent.getContentStream(), 0, newContent.getContentStream().length());
}
catch (IOException e) {
throw new PDFInvalidDocumentException("Cannot get bytes.", (Throwable)e);
}
this.defaultAp = newDefAp = PDFDefaultAppearance.newInstance(this.defaultAp.getPDFDocument(), bytes);
return this.defaultAp;
}
private ASName getPDFColorSpace(ASName colorSpace, double[] value) throws PDFInvalidDocumentException, PDFUnableToCompleteOperationException {
if (value.length == 1) {
if (colorSpace.equals((Object)ASName.k_G)) {
return ASName.k_G;
}
if (colorSpace.equals((Object)ASName.k_g)) {
return ASName.k_g;
}
return ASName.k_g;
}
if (value.length == 3) {
if (colorSpace.equals((Object)ASName.k_RG)) {
return ASName.k_RG;
}
if (colorSpace.equals((Object)ASName.k_rg)) {
return ASName.k_rg;
}
return ASName.k_rg;
}
if (value.length == 4) {
if (colorSpace.equals((Object)ASName.k_K)) {
return ASName.k_K;
}
if (colorSpace.equals((Object)ASName.k_k)) {
return ASName.k_k;
}
return ASName.k_k;
}
throw new PDFInvalidDocumentException("Color array size is incorrect.");
}
private Instruction createColorInstruction() throws PDFInvalidDocumentException {
if (this.colorSpace.equals((Object)ASName.k_g)) {
return InstructionFactory.newDeviceGrayFill(this.fontColor[0]);
}
if (this.colorSpace.equals((Object)ASName.k_G)) {
return InstructionFactory.newDeviceGrayStroke(this.fontColor[0]);
}
if (this.colorSpace.equals((Object)ASName.k_rg)) {
return InstructionFactory.newDeviceRGBFill(this.fontColor[0], this.fontColor[1], this.fontColor[2]);
}
if (this.colorSpace.equals((Object)ASName.k_RG)) {
return InstructionFactory.newDeviceRGBStroke(this.fontColor[0], this.fontColor[1], this.fontColor[2]);
}
if (this.colorSpace.equals((Object)ASName.k_k)) {
return InstructionFactory.newDeviceCMYKFill(this.fontColor[0], this.fontColor[1], this.fontColor[2], this.fontColor[3]);
}
if (this.colorSpace.equals((Object)ASName.k_K)) {
return InstructionFactory.newDeviceCMYKStroke(this.fontColor[0], this.fontColor[1], this.fontColor[2], this.fontColor[3]);
}
throw new PDFInvalidDocumentException("Color space is not recognizable.");
}
private void updateFontName() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, PDFUnableToCompleteOperationException {
ASName base14Name;
PDFFontMap fontMap = this.defaultAp.getPDFDocument().getInteractiveForm().getResources().getFontMap();
if (fontMap != null) {
List fontKeyList = fontMap.getCosDictionary().getKeys();
for (int i = 0; i < fontKeyList.size(); ++i) {
if (!this.baseFontName.equals(fontMap.get((ASName)fontKeyList.get(i)).getBaseFont().asString())) continue;
this.fontName = ((ASName)fontKeyList.get(i)).asString();
return;
}
}
if ((base14Name = StandardFontUtils.getStandardFontProperName(ASName.create((String)this.baseFontName))) == null) {
throw new PDFInvalidDocumentException("Cannot find font.");
}
this.fontName = base14Name.asString();
}
private void updateBaseFontName() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, PDFUnableToCompleteOperationException {
PDFFontMap fontMap = this.defaultAp.getPDFDocument().getInteractiveForm().getResources().getFontMap();
PDFFont pdfFont = null;
if (fontMap != null) {
pdfFont = fontMap.get(ASName.create((String)this.fontName));
}
if (pdfFont != null) {
this.baseFontName = pdfFont.getBaseFont().asString();
return;
}
ASName base14Name = StandardFontUtils.getStandardFontProperName(ASName.create((String)this.fontName));
if (base14Name == null) {
throw new PDFInvalidDocumentException("Cannot find font.");
}
this.baseFontName = base14Name.asString();
}
private byte[] getBytes(InputByteStream stream, int offset, long length) throws IOException {
byte[] bytes = new byte[(int)length];
int counter = 0;
stream.seek((long)offset);
while (!stream.eof()) {
bytes[++counter - 1] = (byte)stream.read();
if ((long)counter != length) continue;
}
return bytes;
}
public Double getCharSpacing() {
return this.charSpacing;
}
public void setCharSpacing(Double charSpacing) {
this.charSpacing = charSpacing;
}
public Double getWordSpacing() {
return this.wordSpacing;
}
public void setWordSpacing(Double wordSpacing) {
this.wordSpacing = wordSpacing;
}
public Double getScale() {
return this.scale;
}
public void setScale(Double scale) {
this.scale = scale;
}
public Double getRise() {
return this.rise;
}
public void setRise(Double rise) {
this.rise = rise;
}
public Double getLeading() {
return this.leading;
}
public void setLeading(Double leading) {
this.leading = leading;
}
public double[] getFillColor() throws PDFSecurityException, PDFIOException, PDFInvalidDocumentException, PDFUnableToCompleteOperationException {
return this.fillColor;
}
public double[] getStrokeColor() throws PDFSecurityException, PDFIOException, PDFInvalidDocumentException, PDFUnableToCompleteOperationException {
return this.strokeColor;
}
static /* synthetic */ double[] access$400(PDFDefaultAppearanceWrapper x0) {
return x0.fillColor;
}
static /* synthetic */ double[] access$500(PDFDefaultAppearanceWrapper x0) {
return x0.strokeColor;
}
}