From 0d2fc1688100f69644e3238da941f6f0c7b4618a Mon Sep 17 00:00:00 2001 From: Paul Gardiner Date: Mon, 4 Feb 2013 16:30:23 +0000 Subject: Android: zooming in reflow mode altering CSS fontSize via javascript --- android/src/com/artifex/mupdfdemo/MuPDFCore.java | 2 +- android/src/com/artifex/mupdfdemo/MuPDFReflowView.java | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'android/src/com/artifex/mupdfdemo') 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 += "
"; + res += "
"; 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() { @@ -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) { -- cgit v1.2.3