From 05d8a59af925b23a8d05c7ec95dcd9bbb0697f97 Mon Sep 17 00:00:00 2001 From: Paul Gardiner Date: Fri, 1 Feb 2013 14:36:52 +0000 Subject: Android: quick and dirty conversion of text to html --- android/src/com/artifex/mupdfdemo/MuPDFCore.java | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'android/src') 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 += ""; + + boolean first = true; + for (TextChar[][][] bl: chars) { + if (!first) res += "

"; + 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 += ""; + + return res; + } + public synchronized TextWord [][] textLines(int page) { gotoPage(page); TextChar[][][][] chars = text(); -- cgit v1.2.3