diff options
author | Paul Gardiner <paulg.artifex@glidos.net> | 2013-02-04 16:30:23 +0000 |
---|---|---|
committer | Paul Gardiner <paulg.artifex@glidos.net> | 2013-02-04 16:30:23 +0000 |
commit | 0d2fc1688100f69644e3238da941f6f0c7b4618a (patch) | |
tree | 8030e7b0c56031198db12a0c275c803df70f5fd8 /android/src/com/artifex/mupdfdemo | |
parent | 21f987ab2584486d68e97029f2c932e88a35a1a6 (diff) | |
download | mupdf-0d2fc1688100f69644e3238da941f6f0c7b4618a.tar.xz |
Android: zooming in reflow mode altering CSS fontSize via javascript
Diffstat (limited to 'android/src/com/artifex/mupdfdemo')
-rw-r--r-- | android/src/com/artifex/mupdfdemo/MuPDFCore.java | 2 | ||||
-rw-r--r-- | android/src/com/artifex/mupdfdemo/MuPDFReflowView.java | 12 |
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) { |