PDFDefaultAppearance.java
4.88 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.pdftoolkit.core.cos.CosObject
* com.adobe.internal.pdftoolkit.core.cos.CosString
* 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
* com.adobe.internal.pdftoolkit.core.types.ASString
*/
package com.adobe.internal.pdftoolkit.pdf.interactive.forms;
import com.adobe.internal.pdftoolkit.core.cos.CosObject;
import com.adobe.internal.pdftoolkit.core.cos.CosString;
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.core.types.ASString;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosObject;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
public class PDFDefaultAppearance
extends PDFCosObject {
private PDFDefaultAppearance(CosObject cosObject) throws PDFInvalidDocumentException {
super(cosObject);
}
public static PDFDefaultAppearance getInstance(CosObject cosObject) throws PDFInvalidDocumentException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFDefaultAppearance object = PDFCosObject.getCachedInstance(cosObject, PDFDefaultAppearance.class);
PDFDefaultAppearance pdfObject = object;
if (pdfObject == null) {
pdfObject = new PDFDefaultAppearance(cosObject);
}
return pdfObject;
}
public static PDFDefaultAppearance newInstance(PDFDocument pdfDocument, byte[] bytes) throws PDFInvalidDocumentException {
CosString cosObject = PDFCosObject.newCosString(pdfDocument, bytes);
return new PDFDefaultAppearance((CosObject)cosObject);
}
public static PDFDefaultAppearance newInstance(PDFDocument pdfDocument, String stringValue) throws PDFInvalidDocumentException {
CosString cosObject = PDFCosObject.newCosString(pdfDocument, stringValue);
return new PDFDefaultAppearance((CosObject)cosObject);
}
public static PDFDefaultAppearance newInstance(PDFDocument pdfDocument, ASName fontResourceName, int size, double greyValue) throws PDFUnableToCompleteOperationException, PDFInvalidDocumentException {
CosString cosObject = PDFCosObject.newCosString(pdfDocument, "/" + fontResourceName.asString() + " " + String.valueOf(size) + " Tf " + ASNumber.doubleToString((double)greyValue) + " g");
return new PDFDefaultAppearance((CosObject)cosObject);
}
public static PDFDefaultAppearance newInstance(PDFDocument pdfDocument, ASName fontResourceName, double size, double[] color) throws PDFInvalidDocumentException {
StringBuilder daStr = new StringBuilder();
daStr.append("/").append(fontResourceName.asString()).append(" ").append(ASNumber.doubleToString((double)size)).append(" Tf ");
if (color != null && color.length > 0) {
if (color.length == 1) {
daStr.append(ASNumber.doubleToString((double)color[0])).append(" g");
} else if (color.length == 3) {
daStr.append(ASNumber.doubleToString((double)color[0])).append(" ").append(ASNumber.doubleToString((double)color[1])).append(" ").append(ASNumber.doubleToString((double)color[2])).append(" rg");
} else if (color.length == 4) {
daStr.append(ASNumber.doubleToString((double)color[0])).append(" ").append(ASNumber.doubleToString((double)color[1])).append(" ").append(ASNumber.doubleToString((double)color[2])).append(" ").append(ASNumber.doubleToString((double)color[3])).append(" k");
}
}
return new PDFDefaultAppearance((CosObject)PDFCosObject.newCosString(pdfDocument, daStr.toString()));
}
public String asString() throws PDFSecurityException {
CosObject cosValue = this.getCosObject();
if (cosValue == null) {
return null;
}
if (cosValue.getType() != 4) {
return null;
}
ASString value = cosValue.stringValue();
return value == null ? null : value.asString();
}
public byte[] asByteArray() throws PDFSecurityException {
CosObject cosValue = this.getCosObject();
if (cosValue == null) {
return null;
}
if (cosValue.getType() != 4) {
return null;
}
CosString cosStringValue = (CosString)cosValue;
return cosStringValue.byteArrayValue();
}
}