我正在尝试使用 Google Docs gview 在我的 WebView 中加载 pdf。它正在加载查看器,但未显示 pdf 页面本身。我已经将这种技术用于其他项目(其他目标 url),没有任何问题,但我无法让 Google Docs Gview 页面使用它。我用
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webview = (WebView) findViewById(R.id.webView1);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new MyWebViewClient());
HttpHelper httphelper = new HttpHelper();
String pdf = "https://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf";
String result = httphelper.GetPage(Uri.parse("https://docs.google.com/gview?embedded=true&url=" + pdf));
webview.loadDataWithBaseURL("https://docs.google.com", result, "text/html", "utf-8", "https://docs.google.com");
}
知道为什么这不适用于 gview 页面吗?
谢谢
最佳答案
mWebview.getSettings().setJavaScriptEnabled(true);
String strPdf="https://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf";
mWebview.loadUrl("https://docs.google.com/gview?embedded=true&url=" + strPdf);
关于java - 使用 Google Docs gview 在 webview 中加载 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9382310/