diff options
author | Paul Gardiner <paulg.artifex@glidos.net> | 2013-02-01 14:36:52 +0000 |
---|---|---|
committer | Paul Gardiner <paulg.artifex@glidos.net> | 2013-02-01 14:36:52 +0000 |
commit | 05d8a59af925b23a8d05c7ec95dcd9bbb0697f97 (patch) | |
tree | 8c73b048ecb6a15fc7d0946f143878c4dcf5e1ba /android/src | |
parent | b029492aa4662a18e74eae8f9ee53941299de72a (diff) | |
download | mupdf-05d8a59af925b23a8d05c7ec95dcd9bbb0697f97.tar.xz |
Android: quick and dirty conversion of text to html
Diffstat (limited to 'android/src')
-rw-r--r-- | android/src/com/artifex/mupdfdemo/MuPDFCore.java | 30 |
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 += "<";break; + case '>': res += ">";break; + case '&': res += "&";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(); |