summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorPaul Gardiner <paulg.artifex@glidos.net>2013-02-01 14:36:52 +0000
committerPaul Gardiner <paulg.artifex@glidos.net>2013-02-01 14:36:52 +0000
commit05d8a59af925b23a8d05c7ec95dcd9bbb0697f97 (patch)
tree8c73b048ecb6a15fc7d0946f143878c4dcf5e1ba /android
parentb029492aa4662a18e74eae8f9ee53941299de72a (diff)
downloadmupdf-05d8a59af925b23a8d05c7ec95dcd9bbb0697f97.tar.xz
Android: quick and dirty conversion of text to html
Diffstat (limited to 'android')
-rw-r--r--android/src/com/artifex/mupdfdemo/MuPDFCore.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFCore.java b/android/src/com/artifex/mupdfdemo/MuPDFCore.java
index 73db5073..6d4e5b67 100644
--- a/android/src/com/artifex/mupdfdemo/MuPDFCore.java
+++ b/android/src/com/artifex/mupdfdemo/MuPDFCore.java
@@ -200,6 +200,36 @@ public class MuPDFCore
return searchPage(text);
}
+ public synchronized String html(int page) {
+ gotoPage(page);
+ TextChar[][][][] chars = text();
+ String res = new String();
+
+ res += "<html><body>";
+
+ boolean first = true;
+ for (TextChar[][][] bl: chars) {
+ if (!first) res += "<p>";
+ first = false;
+ for (TextChar[][] ln: bl) {
+ for (TextChar[] sp: ln) {
+ for (TextChar tc: sp) {
+ switch (tc.c) {
+ case '<': res += "&lt;";break;
+ case '>': res += "&gt;";break;
+ case '&': res += "&amp;";break;
+ default: res += (tc.c >= 32 && tc.c <= 127) ? tc.c : "#x"+Integer.toHexString(tc.c);
+ }
+ }
+ }
+ }
+ }
+
+ res += "</body></html>";
+
+ return res;
+ }
+
public synchronized TextWord [][] textLines(int page) {
gotoPage(page);
TextChar[][][][] chars = text();