TextObject.java
5.53 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* 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.ASArray
* com.adobe.internal.pdftoolkit.core.types.ASMatrix
* com.adobe.internal.pdftoolkit.core.types.ASString
*/
package com.adobe.internal.pdftoolkit.pdf.content.processor;
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.ASArray;
import com.adobe.internal.pdftoolkit.core.types.ASMatrix;
import com.adobe.internal.pdftoolkit.core.types.ASString;
import com.adobe.internal.pdftoolkit.pdf.content.processor.ActualText;
import com.adobe.internal.pdftoolkit.pdf.content.processor.GState;
import com.adobe.internal.pdftoolkit.pdf.content.processor.TextRun;
import com.adobe.internal.pdftoolkit.pdf.content.processor.TextRunList;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import java.util.MissingResourceException;
public class TextObject {
private boolean ignoreErrors;
private TextRunList textRuns = new TextRunList();
private ASMatrix tm = ASMatrix.createIdentityMatrix();
private ASMatrix tlm = ASMatrix.createIdentityMatrix();
private ASMatrix trm = ASMatrix.createIdentityMatrix();
private PDFDocument pdfDocument;
private boolean skipThisTextObject = false;
public TextObject(PDFDocument pdfDocument, boolean ignoreErrors) {
this.pdfDocument = pdfDocument;
this.ignoreErrors = ignoreErrors;
}
public TextObject(TextObject textObj, boolean ignoreErrors) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.pdfDocument = textObj.pdfDocument;
this.ignoreErrors = ignoreErrors;
this.textRuns = new TextRunList(textObj.getTextRuns());
this.tm = textObj.getTextMatrix();
this.tlm = textObj.getTextLineMatrix();
this.trm = textObj.getTextRenderingMatrix();
}
public TextRunList getTextRuns() {
return this.textRuns;
}
public void addTextRun(ASString string, GState gState) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
try {
if (string.getBytes() != null && string.getBytes().length != 0) {
TextRun textRun = new TextRun(string, this.tm, gState, this.pdfDocument, this.ignoreErrors);
this.textRuns.add(textRun);
this.adjustTextMatrix(textRun);
}
}
catch (MissingResourceException e) {
}
catch (PDFInvalidDocumentException e) {
// empty catch block
}
}
public void addTextRun(ASString string, GState gState, ActualText actualText) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
try {
if (string.getBytes() != null && string.getBytes().length != 0) {
TextRun textRun = new TextRun(string, this.tm, gState, actualText, this.pdfDocument, this.ignoreErrors);
this.textRuns.add(textRun);
this.adjustTextMatrix(textRun);
}
}
catch (MissingResourceException e) {
}
catch (PDFInvalidDocumentException e) {
// empty catch block
}
}
public void addTextRun(ASArray tjArray, GState gState) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
try {
TextRun textRun = new TextRun(tjArray, this.tm, gState, this.pdfDocument, this.ignoreErrors);
this.textRuns.add(textRun);
this.adjustTextMatrix(textRun);
}
catch (MissingResourceException e) {
}
catch (PDFInvalidDocumentException e) {
// empty catch block
}
}
public void addTextRun(ASArray tjArray, GState gState, ActualText actualText) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
try {
TextRun textRun = new TextRun(tjArray, this.tm, gState, actualText, this.pdfDocument, this.ignoreErrors);
this.textRuns.add(textRun);
this.adjustTextMatrix(textRun);
}
catch (MissingResourceException e) {
}
catch (PDFInvalidDocumentException e) {
// empty catch block
}
}
void adjustTextMatrix(TextRun textRun) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.tm = this.tm.preMultiply(textRun.txDelta, textRun.tyDelta);
}
public ASMatrix getTextMatrix() {
return this.tm;
}
public void setTextMatrix(ASMatrix tm) {
this.tm = tm;
}
public ASMatrix getTextLineMatrix() {
return this.tlm;
}
public void setTextLineMatrix(ASMatrix tlm) {
this.tlm = tlm;
}
ASMatrix getTextRenderingMatrix() {
return this.trm;
}
void setTextRenderingMatrix(ASMatrix trm) {
this.trm = trm;
}
public String toString() {
return this.textRuns.toString();
}
public boolean ignoreErrors() {
return this.ignoreErrors;
}
public void setSkipThisTextObject(boolean skipThisTextObject) {
this.skipThisTextObject = skipThisTextObject;
}
public boolean skipThisTextObject() {
return this.skipThisTextObject;
}
}