How to open pdf from url in webview that's not ends with ".pdf"?

136 Views Asked by At

I searched how to open pdf document in webview. I can open any url that ends withs '.pdf' but I need open a url that's not ends with '.pdf'. I can not solve this.

@SuppressLint("SetJavaScriptEnabled")
override fun onCreateFinished() {
    binding.webView.webViewClient = WebViewClient()
    binding.webView.settings.javaScriptEnabled = true
    binding.webView.settings.displayZoomControls = true
    val url = "urlEndsWithout.pdf"
    val googleDocsUrl = "https://docs.google.com/gview?embedded=true&url="+url
    binding.webView.loadUrl(googleDocsUrl)
}

That is error I get it: "Unrecognized Content-Security-Policy directive 'require-trusted-types-for'. ", source: https://content.googleapis.com/static/proxy.html?usegapi=1&jsh=m%3B%2F_%2Fscs%2Fabc-static%2F_%2Fjs%2Fk%3Dgapi.lb.en.S9zOXUg9rrA.O%2Fd%3D1%2Frs%3DAHpOoo-AXjUK4hNAaKzui0P9Fr9nG2_yZQ%2Fm%3D__features__#parent=https%3A%2F%2Fdocs.google.com&rpctoken=887135553

0

There are 0 best solutions below