PDFFieldBarcode.java
4.78 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
/*
* 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.interactive.forms;
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.PDFCosObject;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import com.adobe.internal.pdftoolkit.pdf.graphics.PDFRectangle;
import com.adobe.internal.pdftoolkit.pdf.interactive.annotation.PDFAnnotationWidget;
import com.adobe.internal.pdftoolkit.pdf.interactive.annotation.PDFPaperMetaData;
import com.adobe.internal.pdftoolkit.pdf.interactive.forms.PDFDefaultAppearance;
import com.adobe.internal.pdftoolkit.pdf.interactive.forms.PDFFieldNode;
import com.adobe.internal.pdftoolkit.pdf.interactive.forms.PDFFieldText;
import com.adobe.internal.pdftoolkit.pdf.page.PDFPage;
import java.util.HashMap;
import java.util.Map;
public class PDFFieldBarcode
extends PDFFieldText {
public static final ASName k_DataPrep = ASName.create((String)"DataPrep");
private static final String DEFAULT_BARCODEFIELD_NAME = "Barcode";
private PDFFieldBarcode(CosObject cosObject) throws PDFInvalidDocumentException {
super(cosObject);
}
public static PDFFieldBarcode getInstance(CosObject cosObject) throws PDFInvalidDocumentException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFFieldBarcode pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFFieldBarcode.class);
if (pdfObject == null) {
pdfObject = new PDFFieldBarcode(cosObject);
}
return pdfObject;
}
public static PDFFieldNode newInstance(PDFPage page, PDFRectangle annotRect, PDFFieldNode parent, PDFPaperMetaData pmd) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, PDFInvalidParameterException {
CosDictionary cosObject = PDFCosObject.newCosDictionary(page.getPDFDocument());
PDFFieldBarcode field = new PDFFieldBarcode((CosObject)cosObject);
field.setDataPrep(DataPrep.DATA_SENT_TO_ENCODER_DIRECTLY);
field.init(parent, null, page, annotRect, true, pmd);
return field;
}
private void init(PDFFieldNode parent, String fieldName, PDFPage page, PDFRectangle annotRect, boolean combineFieldAnnot, PDFPaperMetaData pmd) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, PDFInvalidParameterException {
this.init(parent, fieldName, "Barcode", null, false);
PDFAnnotationWidget widget = this.initWidgetAnnot(page, annotRect, combineFieldAnnot);
this.setDictionaryNameValue(ASName.k_FT, ASName.k_Tx);
widget.setPMD(pmd);
}
public DataPrep getDataPrep() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return DataPrep.get(this.getDictionaryIntValue(k_DataPrep));
}
public void setDataPrep(DataPrep value) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryIntValue(k_DataPrep, value.getCode());
}
public boolean hasDataPrep() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(k_DataPrep);
}
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public static enum DataPrep {
DATA_SENT_TO_ENCODER_DIRECTLY(0),
DATA_COMPRESSED_FIRST(1);
private int code;
private static final Map<Integer, DataPrep> lookup;
private DataPrep(int code) {
this.code = code;
}
public int getCode() {
return this.code;
}
public static DataPrep get(int code) {
return lookup.get(code);
}
static {
lookup = new HashMap<Integer, DataPrep>();
lookup.put(0, DATA_SENT_TO_ENCODER_DIRECTLY);
lookup.put(1, DATA_COMPRESSED_FIRST);
}
}
}