-
android在线查看pdf文档下载
资源介绍
pdfShowWebView = (WebView) findViewById(R.id.pdf_show_webview);
pdfShowWebView.setWebViewClient(new WebViewClient()
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
// 返回值是true的时候控制去WebView打开,为false调用系统浏览器或第三方浏览器
view.loadUrl(url);
return true;
}
});
WebSettings settings = pdfShowWebView.getSettings();
settings.setSavePassword(false);
settings.setJavaScriptEnabled(true);
settings.setAllowFileAccessFromFileURLs(true);
settings.setAllowUniversalAccessFromFileURLs(true);
settings.setBuiltInZoomControls(true);
pdfShowWebView.setWebChromeClient(new WebChromeClient());
if (!"".equals(docPath))
{
byte[] bytes = null;
try
{// 获取以字符编码为utf-8的字符
bytes = docPath.getBytes("UTF-8");
}
catch (UnsupportedEncodingException e1)
{
e1.printStackTrace();
}
if (bytes != null)
{
docPath = new BASE64Encoder().encode(bytes);// BASE64转码
}
}
pdfShowWebView.loadUrl("file:///android_asset/pdfjs/web/viewer.html?file="+ docPath);
- 上一篇: android打开网络pdf文件
- 下一篇: android pdf