summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/src/com/artifex/mupdfdemo/MuPDFCore.java2
-rw-r--r--android/src/com/artifex/mupdfdemo/MuPDFReflowView.java12
2 files changed, 10 insertions, 4 deletions
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFCore.java b/android/src/com/artifex/mupdfdemo/MuPDFCore.java
index 68c38a7f..b74c6593 100644
--- a/android/src/com/artifex/mupdfdemo/MuPDFCore.java
+++ b/android/src/com/artifex/mupdfdemo/MuPDFCore.java
@@ -205,7 +205,7 @@ public class MuPDFCore
TextChar[][][][] chars = text();
String res = new String();
- res += "<html><body><div>";
+ res += "<html><body style=\"margin:0\"><div style=\"padding:10px\" id=\"content\">";
boolean first = true;
for (TextChar[][][] bl: chars) {
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java b/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java
index e5992e46..8824436f 100644
--- a/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java
+++ b/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java
@@ -26,6 +26,12 @@ public class MuPDFReflowView extends WebView implements MuPDFView {
mContentHeight = parentSize.y;
}
+ private void requestHeight() {
+ // Get the webview to report the content height via the interface setup
+ // above. Workaround for getContentHeight not working
+ loadUrl("javascript:elem=document.getElementById('content');window.HTMLOUT.reportContentHeight("+mParentSize.x+"*elem.offsetHeight/elem.offsetWidth)");
+ }
+
public void setPage(int page, PointF size) {
mPage = page;
getSettings().setJavaScriptEnabled(true);
@@ -37,9 +43,7 @@ public class MuPDFReflowView extends WebView implements MuPDFView {
setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
- // Get the webview to report the content height via the interface setup
- // above. Workaround for getContentHeight not working
- view.loadUrl("javascript:elem=document.getElementsByTagName('html')[0];window.HTMLOUT.reportContentHeight("+mParentSize.x+"*elem.offsetHeight/elem.offsetWidth)");
+ requestHeight();
}
});
mLoadHTML = new AsyncTask<Void,Void,String>() {
@@ -67,6 +71,8 @@ public class MuPDFReflowView extends WebView implements MuPDFView {
}
public void setScale(float scale) {
+ loadUrl("javascript:document.getElementById('content').style.fontSize=\""+(int)(scale*100)+"%\"");
+ requestHeight();
}
public void blank(int page) {