[英]Opening pdf of sd card in webview
i am trying to load pdf in webview from my sdcard but it gives message 我正在尝试从我的sdcard加载webview中的pdf文件,但它给出了消息
" Sorry, we were unable to find the document at the original source. Verify that the document still exists! " “ 很抱歉,我们无法在原始来源找到该文档。请确认该文档仍然存在! ”
i also googled this but after banging my head a lot i got nothing than this one and this one ... 我也用Google搜索这一点,但敲我的头后有很多我没有什么比这一个 ,这一个 ...
webView = (WebView) findViewById(R.id.webview_compontent);
fill_form = (Button) findViewById(R.id.fill_form);
fill_form.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "In Progress", Toast.LENGTH_LONG).show();
}
});
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
// webView.getSettings().setUseWideViewPort(true);
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
progDailog.show();
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, final String url) {
progDailog.dismiss();
}
});
// String fileurl = Environment.getExternalStorageDirectory()+File.separator +"pk.pdf";
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+File.separator+"pk.pdf");
Uri fileurl = (Uri.fromFile(file));
String Url = "http://docs.google.com/gview?embedded=true&url=" + fileurl;
webView.loadUrl(Url);
}
Please give any idea how to do this ?(I don't want to use any payable rendering library.) 请告诉我如何执行此操作?(我不想使用任何付费渲染库。)
I don't think that webview can load a pdf for you. 我认为webview不能为您加载pdf。 Sso you still have two options: 1. Try to ask other applications to view this PDF for you. Sso您仍然有两个选择:1.尝试让其他应用程序为您查看此PDF。 2. You can try this librarry https://github.com/JoanZapata/android-pdfview if GNU policy suits you. 2.如果GNU政策适合您,则可以尝试使用该库https://github.com/JoanZapata/android-pdfview 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.