Android Webview有时无法呈现pdf,而是显示空白/白色页面
2022-09-02 20:59:57
- 使用谷歌文档在网络视图中打开PDF
- 一次又一次地打开相同的pdf或不同的pdf。
- 有时它会在Android中显示空白/白色页面,直到我们再次刷新网页1或2次。
我已经在pdf上制作了示例。该项目的链接如下所示:
https://github.com/gopalawasthi123/PdfWebView
希望这会更好地帮助你。
public void SetWebView(WebView webview,string externalUrl){
webview.Tag = "webview";
webview.Settings.JavaScriptEnabled = true;
webview.Settings.SupportZoom ();
webview.Settings.SetAppCacheEnabled(true);
webview.Settings.DomStorageEnabled = true;
webview.ZoomOut ();
webview.ZoomIn ();
webview.Settings.BuiltInZoomControls = true;
webview.Settings.LoadWithOverviewMode = true;
webview.Settings.UseWideViewPort = true;
//webview.Settings.SetSupportZoom (true);
webview.Settings.SetPluginState (WebSettings.PluginState.On);
webview.Settings.GetPluginState ();
if (externalUrl.StartsWith("http://") || externalUrl.StartsWith("https://"))
webview.LoadUrl (externalUrl);
webview.SetWebViewClient (new MonkeyWebViewClient (imgViewBack, imgViewForward, imgRefresh));
webview.SetWebChromeClient (new WebChromeClient ());
}