I am using to webview loading pdf file in webview. I am facing an issue where the webview is showing a top side corner icon. I want to disable or hide this icon. I also need a zoom in and zoom out option. Can you please help me resolve this issue? I have attached a snap for your reference and i have attached my code as well.
class PdfViewer : AppCompatActivity() {
private val LOADER_ID = 1
// private val pdfView: PDFView by lazy { findViewById(R.id.pdfView) }
private var progressViewBar: ProgressBar? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.pdf_viewer)
val webView: WebView = findViewById(R.id.webView)
window.setFlags(
WindowManager.LayoutParams.FLAG_SECURE,
WindowManager.LayoutParams.FLAG_SECURE
)
// Get the PDF URL from the intent
val pdfUrl ="https://home.uchicago.edu/~jcarlsen/2007/downloads/Selections.pdf"
// Ensure that the PDF URL is not null
if (!pdfUrl.isNullOrBlank()) {
// Enable JavaScript (required for PDF.js)
webView.settings.javaScriptEnabled = true
webView.settings.builtInZoomControls = true
// webView.settings.displayZoomControls=false
webView.webViewClient = WebViewClient()
try {
val encode_url =
URLEncoder.encode(pdfUrl, "UTF-8") //Url
webView.loadUrl("https://docs.google.com/viewerng/viewer?embedded=true&url=" + encode_url);
// Convert to UTF-8 It important.
} catch (e: UnsupportedEncodingException) {
e.printStackTrace()
}
// Load the PDF viewer HTML file with the dynamic PDF URL
} else {
// Handle case where PDF URL is null
}
}
}
