forked from tabulapdf/tabula-java
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTextChunkSerializer.java
More file actions
27 lines (20 loc) · 882 Bytes
/
TextChunkSerializer.java
File metadata and controls
27 lines (20 loc) · 882 Bytes
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
package technology.tabula.json;
import java.lang.reflect.Type;
import technology.tabula.RectangularTextContainer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
public class TextChunkSerializer implements JsonSerializer<RectangularTextContainer> {
@Override
public JsonElement serialize(RectangularTextContainer textChunk, Type arg1,
JsonSerializationContext context) {
JsonObject object = new JsonObject();
object.addProperty("top", textChunk.getTop());
object.addProperty("left", textChunk.getLeft());
object.addProperty("width", textChunk.getWidth());
object.addProperty("height", textChunk.getHeight());
object.addProperty("text", textChunk.getText());
return object;
}
}