Content.java
4.36 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.io.stream.InputByteStream
* com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException
*/
package com.adobe.internal.pdftoolkit.pdf.content;
import com.adobe.internal.io.stream.InputByteStream;
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.pdf.document.PDFContents;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import com.adobe.internal.pdftoolkit.pdf.document.PDFResources;
import com.adobe.internal.pdftoolkit.pdf.graphics.xobject.PDFXObjectForm;
import com.adobe.internal.pdftoolkit.pdf.page.PDFPage;
public class Content {
protected PDFDocument document;
protected PDFResources resources;
protected PDFContents contents;
protected boolean resourcesDetached;
protected boolean contentsDetached;
protected Content(PDFDocument pdfDocument) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.document = pdfDocument;
this.contents = PDFContents.newInstance(pdfDocument);
this.resources = PDFResources.newInstance(pdfDocument);
}
protected Content(PDFContents contents, boolean contentDetached, PDFResources resources, boolean resourcesDetached) {
this.document = contents.getPDFDocument();
this.contents = contents;
this.contentsDetached = contentDetached;
this.resources = resources;
this.resourcesDetached = resourcesDetached;
}
public static Content newInstance(PDFContents contents, PDFResources resources) {
return new Content(contents, false, resources, false);
}
public static Content newInstance(PDFXObjectForm xobjectForm) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFContents contents = xobjectForm.getContents();
PDFResources resources = xobjectForm.getResources();
boolean contentDetached = false;
boolean resourcesDetached = false;
if (contents == null) {
contents = PDFContents.newInstance(xobjectForm.getPDFDocument());
contentDetached = true;
}
if (resources == null) {
resources = PDFResources.newInstance(xobjectForm.getPDFDocument());
resourcesDetached = true;
}
return new Content(contents, contentDetached, resources, resourcesDetached);
}
public static Content newInstance(PDFPage page) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFContents contents = page.getContents();
PDFResources resources = page.getResources();
boolean contentDetached = false;
boolean resourcesDetached = false;
if (contents == null) {
contents = PDFContents.newInstance(page.getPDFDocument());
contentDetached = true;
}
if (resources == null) {
resources = PDFResources.newInstance(page.getPDFDocument());
resourcesDetached = true;
}
return new Content(contents, contentDetached, resources, resourcesDetached);
}
public static Content getInstance(PDFContents contents, PDFResources resources) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return new Content(contents, false, resources, false);
}
public static Content newInstance(PDFDocument pdfDocument) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return new Content(pdfDocument);
}
public PDFContents getContents() {
return this.contents;
}
public boolean contentsDetached() {
return this.contentsDetached;
}
public InputByteStream getContentStream() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.contents.getContents();
}
public PDFResources getResources() {
return this.resources;
}
public boolean resourcesDetached() {
return this.resourcesDetached;
}
public PDFDocument getPDFDocument() {
return this.document;
}
}