PDFDestinationExplicit.java
14.4 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.pdftoolkit.core.cos.CosArray
* com.adobe.internal.pdftoolkit.core.cos.CosDocument
* com.adobe.internal.pdftoolkit.core.cos.CosName
* com.adobe.internal.pdftoolkit.core.cos.CosNull
* com.adobe.internal.pdftoolkit.core.cos.CosNumeric
* 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
* com.adobe.internal.pdftoolkit.core.types.ASString
*/
package com.adobe.internal.pdftoolkit.pdf.interactive.navigation;
import com.adobe.internal.pdftoolkit.core.cos.CosArray;
import com.adobe.internal.pdftoolkit.core.cos.CosDocument;
import com.adobe.internal.pdftoolkit.core.cos.CosName;
import com.adobe.internal.pdftoolkit.core.cos.CosNull;
import com.adobe.internal.pdftoolkit.core.cos.CosNumeric;
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.core.types.ASString;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosObject;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import com.adobe.internal.pdftoolkit.pdf.interactive.navigation.PDFDestination;
import com.adobe.internal.pdftoolkit.pdf.page.PDFPage;
import com.adobe.internal.pdftoolkit.pdf.page.PDFPageFit;
public class PDFDestinationExplicit
extends PDFDestination {
private PDFDestinationExplicit(CosObject cosObject) throws PDFInvalidDocumentException {
super(cosObject);
}
public static PDFDestinationExplicit getInstance(CosObject cosObject) throws PDFInvalidDocumentException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFDestinationExplicit pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFDestinationExplicit.class);
if (pdfObject == null) {
pdfObject = new PDFDestinationExplicit(cosObject);
}
return pdfObject;
}
public static PDFDestinationExplicit newSkeletonInstance(PDFDocument pdfDocument) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return PDFDestinationExplicit.getInstance((CosObject)PDFCosObject.newCosArray(pdfDocument));
}
public static PDFDestinationExplicit newDestXYZ(PDFPage page, float left, float top, float zoom) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = PDFCosObject.newCosArray(page.getPDFDocument());
cosArray.add(page.getCosObject());
cosArray.addName(PDFPageFit.XYZ.getName());
cosArray.addDouble((double)left);
cosArray.addDouble((double)top);
cosArray.addDouble((double)zoom);
return PDFDestinationExplicit.getInstance((CosObject)cosArray);
}
public static PDFDestinationExplicit newDestFit(PDFPage page) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = PDFCosObject.newCosArray(page.getPDFDocument());
CosObject cosPage = page.getCosObject();
cosArray.add(cosPage);
cosArray.addName(PDFPageFit.Fit.getName());
return PDFDestinationExplicit.getInstance((CosObject)cosArray);
}
public static PDFDestinationExplicit newDestFitH(PDFPage page, float top) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = PDFCosObject.newCosArray(page.getPDFDocument());
cosArray.add(page.getCosObject());
cosArray.addName(PDFPageFit.FitH.getName());
cosArray.addDouble((double)top);
return PDFDestinationExplicit.getInstance((CosObject)cosArray);
}
public static PDFDestinationExplicit newDestFitV(PDFPage page, float left) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = PDFCosObject.newCosArray(page.getPDFDocument());
cosArray.add(page.getCosObject());
cosArray.addName(PDFPageFit.FitV.getName());
cosArray.addDouble((double)left);
return PDFDestinationExplicit.getInstance((CosObject)cosArray);
}
public static PDFDestinationExplicit newDestFitR(PDFPage page, float left, float bottom, float right, float top) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = PDFCosObject.newCosArray(page.getPDFDocument());
cosArray.add(page.getCosObject());
cosArray.addName(PDFPageFit.FitR.getName());
cosArray.addDouble((double)left);
cosArray.addDouble((double)bottom);
cosArray.addDouble((double)right);
cosArray.addDouble((double)top);
return PDFDestinationExplicit.getInstance((CosObject)cosArray);
}
public static PDFDestinationExplicit newDestFitB(PDFPage page) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = PDFCosObject.newCosArray(page.getPDFDocument());
CosObject cosPage = page.getCosObject();
cosArray.add(cosPage);
cosArray.addName(PDFPageFit.FitB.getName());
return PDFDestinationExplicit.getInstance((CosObject)cosArray);
}
public static PDFDestinationExplicit newDestFitBH(PDFPage page, float top) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = PDFCosObject.newCosArray(page.getPDFDocument());
cosArray.add(page.getCosObject());
cosArray.addName(PDFPageFit.FitBH.getName());
cosArray.addDouble((double)top);
return PDFDestinationExplicit.getInstance((CosObject)cosArray);
}
public static PDFDestinationExplicit newDestFitBV(PDFPage page, float left) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = PDFCosObject.newCosArray(page.getPDFDocument());
cosArray.add(page.getCosObject());
cosArray.addName(PDFPageFit.FitBV.getName());
cosArray.addDouble((double)left);
return PDFDestinationExplicit.getInstance((CosObject)cosArray);
}
public static PDFDestinationExplicit newDestXYZ(PDFDocument pdfDoc, PDFPage page, Double left, Double top, Double zoom) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = PDFCosObject.newCosArray(pdfDoc);
CosObject cosPage = page != null ? page.getCosObject() : PDFCosObject.newCosNull(pdfDoc);
cosArray.add(cosPage);
cosArray.addName(PDFPageFit.XYZ.getName());
PDFDestinationExplicit.addDoubleValue(cosArray, left);
PDFDestinationExplicit.addDoubleValue(cosArray, top);
PDFDestinationExplicit.addDoubleValue(cosArray, zoom);
return PDFDestinationExplicit.getInstance((CosObject)cosArray);
}
public static PDFDestinationExplicit newDestFit(PDFDocument pdfDoc, PDFPage page) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = PDFCosObject.newCosArray(pdfDoc);
CosObject cosPage = page != null ? page.getCosObject() : PDFCosObject.newCosNull(pdfDoc);
cosArray.add(cosPage);
cosArray.addName(PDFPageFit.Fit.getName());
return PDFDestinationExplicit.getInstance((CosObject)cosArray);
}
public static PDFDestinationExplicit newDestFitH(PDFDocument pdfDoc, PDFPage page, Double top) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = PDFCosObject.newCosArray(pdfDoc);
CosObject cosPage = page != null ? page.getCosObject() : PDFCosObject.newCosNull(pdfDoc);
cosArray.add(cosPage);
cosArray.addName(PDFPageFit.FitH.getName());
PDFDestinationExplicit.addDoubleValue(cosArray, top);
return PDFDestinationExplicit.getInstance((CosObject)cosArray);
}
public static PDFDestinationExplicit newDestFitV(PDFDocument pdfDoc, PDFPage page, Double left) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = PDFCosObject.newCosArray(pdfDoc);
CosObject cosPage = page != null ? page.getCosObject() : PDFCosObject.newCosNull(pdfDoc);
cosArray.add(cosPage);
cosArray.addName(PDFPageFit.FitV.getName());
PDFDestinationExplicit.addDoubleValue(cosArray, left);
return PDFDestinationExplicit.getInstance((CosObject)cosArray);
}
public static PDFDestinationExplicit newDestFitR(PDFDocument pdfDoc, PDFPage page, Double left, Double bottom, Double right, Double top) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = PDFCosObject.newCosArray(pdfDoc);
CosObject cosPage = page != null ? page.getCosObject() : PDFCosObject.newCosNull(pdfDoc);
cosArray.add(cosPage);
cosArray.addName(PDFPageFit.FitR.getName());
PDFDestinationExplicit.addDoubleValue(cosArray, left);
PDFDestinationExplicit.addDoubleValue(cosArray, bottom);
PDFDestinationExplicit.addDoubleValue(cosArray, right);
PDFDestinationExplicit.addDoubleValue(cosArray, top);
return PDFDestinationExplicit.getInstance((CosObject)cosArray);
}
public static PDFDestinationExplicit newDestFitBH(PDFDocument pdfDoc, PDFPage page, Double top) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = PDFCosObject.newCosArray(pdfDoc);
CosObject cosPage = page != null ? page.getCosObject() : PDFCosObject.newCosNull(pdfDoc);
cosArray.add(cosPage);
cosArray.addName(PDFPageFit.FitBH.getName());
PDFDestinationExplicit.addDoubleValue(cosArray, top);
return PDFDestinationExplicit.getInstance((CosObject)cosArray);
}
public static PDFDestinationExplicit newDestFitBV(PDFDocument pdfDoc, PDFPage page, Double left) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = PDFCosObject.newCosArray(pdfDoc);
CosObject cosPage = page != null ? page.getCosObject() : PDFCosObject.newCosNull(pdfDoc);
cosArray.add(cosPage);
cosArray.addName(PDFPageFit.FitBV.getName());
PDFDestinationExplicit.addDoubleValue(cosArray, left);
return PDFDestinationExplicit.getInstance((CosObject)cosArray);
}
private static void addDoubleValue(CosArray destArray, Double value) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (value == null) {
destArray.add((CosObject)destArray.getDocument().createCosNull());
} else {
destArray.addDouble(value.doubleValue());
}
}
public boolean hasPage() throws PDFCosParseException, PDFIOException, PDFSecurityException {
if (this.getCosArray() == null) {
return false;
}
CosObject o = this.getCosArray().get(0);
return o != null && !(o instanceof CosNumeric);
}
public PDFPage getPage() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.getCosArray() == null) {
return null;
}
CosObject o = this.getCosArray().get(0);
if (o == null || o instanceof CosNumeric) {
return null;
}
return PDFPage.getInstance(o);
}
public void setPage(PDFPage page) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosObject cosPage = page == null ? this.getCosObject().getDocument().createCosNull() : page.getCosObject();
this.getCosArray().extendIfNecessaryAndSet(0, cosPage);
}
public boolean hasPageNumber() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.getCosArray() == null) {
return false;
}
CosObject o = this.getCosArray().get(0);
return o != null && o instanceof CosNumeric;
}
public int getPageNumber() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.getCosArray() == null) {
return -1;
}
CosObject o = this.getCosArray().get(0);
if (!(o instanceof CosNumeric)) {
return -1;
}
return ((CosNumeric)o).intValue();
}
public void setPageNumber(int pageNumber) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.getCosArray().extendIfNecessaryAndSet(0, (CosObject)PDFCosObject.newCosNumeric(this.getPDFDocument(), pageNumber));
}
public PDFPageFit getPageFit() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray theArray = this.getCosArray();
if (theArray == null || theArray.size() < 2) {
return null;
}
if (theArray.get(1).getType() == 3) {
return PDFPageFit.getInstance(theArray.getName(1));
}
return null;
}
public void setPageFit(PDFPageFit pageFit) throws PDFCosParseException, PDFIOException, PDFSecurityException {
CosArray array = this.getCosArray();
CosName o = PDFCosObject.newCosName(this.getPDFDocument(), pageFit);
array.extendIfNecessaryAndSet(1, (CosObject)o);
}
public Number[] getCoordinates() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.getCosArray() == null || this.getCosArray().size() < 2) {
return null;
}
int size = this.getCosArray().size() - 2;
Number[] coords = new Number[size];
for (int i = 0; i < size; ++i) {
coords[i] = (Number)this.getCosArray().get(i + 2).getValue();
}
return coords;
}
public void setCoordinates(Number[] coords) throws PDFCosParseException, PDFIOException, PDFSecurityException {
CosArray array = this.getCosArray();
for (int i = 0; i < coords.length; ++i) {
CosNull o = coords[i] == null ? PDFCosObject.newCosNull(this.getPDFDocument()) : PDFCosObject.newCosNumeric(this.getPDFDocument(), coords[i]);
array.extendIfNecessaryAndSet(i + 2, (CosObject)o);
}
}
public ASString getName() {
return null;
}
}