PDFExtension.java
5.14 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.pdftoolkit.core.cos.CosDictionary
* com.adobe.internal.pdftoolkit.core.cos.CosObject
* com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidParameterException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException
* com.adobe.internal.pdftoolkit.core.types.ASName
*/
package com.adobe.internal.pdftoolkit.pdf.document;
import com.adobe.internal.pdftoolkit.core.cos.CosDictionary;
import com.adobe.internal.pdftoolkit.core.cos.CosObject;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidParameterException;
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.PDFDocument;
import com.adobe.internal.pdftoolkit.pdf.document.PDFVersion;
import java.util.HashMap;
import java.util.Map;
public class PDFExtension
extends PDFCosDictionary {
private PDFExtension(CosObject cosObject) throws PDFInvalidDocumentException {
super(cosObject);
}
public static PDFExtension getInstance(CosObject cosObject) throws PDFInvalidDocumentException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFExtension pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFExtension.class);
if (pdfObject == null) {
pdfObject = new PDFExtension(cosObject);
}
return pdfObject;
}
public static PDFExtension newInstance(PDFDocument pdfDocument, PDFVersion baseVersion, int extensionLevel) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (baseVersion == null || baseVersion.getVersionValue() == null) {
throw new PDFInvalidDocumentException("Base version can't be null. It's a required entry");
}
CosDictionary cosObject = PDFCosObject.newCosDirectDictionary(pdfDocument);
PDFExtension pdfObject = new PDFExtension((CosObject)cosObject);
pdfObject.setDictionaryNameValue(ASName.k_BaseVersion, baseVersion.getVersionValue());
pdfObject.setDictionaryIntValue(ASName.k_ExtensionLevel, extensionLevel);
return pdfObject;
}
public void setBaseVerssion(PDFVersion version) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, PDFInvalidParameterException {
this.setDictionaryDoubleValue(ASName.k_BaseVersion, version.asString());
}
public void setExtensionLevel(int extensionLevel) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryIntValue(ASName.k_ExtensionLevel, extensionLevel);
}
private String getBaseVersionAsString() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryNameValueAsString(ASName.k_BaseVersion);
}
public PDFVersion getBaseVersion() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
String sVersion = this.getBaseVersionAsString();
PDFVersion pdfVersion = PDFVersion.getSupportedInstance(sVersion);
if (pdfVersion != null) {
return pdfVersion;
}
return PDFVersion.getInstance(sVersion);
}
public int getExtensionLevel() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryIntValue(ASName.k_ExtensionLevel);
}
protected static PDFExtension newInstance(PDFDocument document, Map extension) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
String baseVersionString = (String)extension.get((Object)ASName.k_BaseVersion);
if (baseVersionString != null) {
PDFVersion baseVersion = PDFVersion.getInstance(baseVersionString);
Integer extensionLevelInt = (Integer)extension.get((Object)ASName.k_ExtensionLevel);
if (extensionLevelInt != null) {
return PDFExtension.newInstance(document, baseVersion, extensionLevelInt);
}
}
return null;
}
public static Map asMap(PDFVersion baseVersion, int extensionLevel) {
HashMap<ASName, Object> extension = new HashMap<ASName, Object>();
extension.put(ASName.k_BaseVersion, baseVersion.asString());
extension.put(ASName.k_ExtensionLevel, extensionLevel);
return extension;
}
protected Map asMap() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
HashMap<ASName, Object> extension = new HashMap<ASName, Object>();
extension.put(ASName.k_BaseVersion, this.getBaseVersionAsString());
extension.put(ASName.k_ExtensionLevel, this.getExtensionLevel());
return extension;
}
}