How to open local pdf file in WebView Android Studio

后端 未结 1 1184
萌比男神i
萌比男神i 2021-01-07 11:11

I am aware that this question has been asked many times, but I still cannot get it to work. I have a pdf in the raw folder and I am trying to open it in a webview using \"ht

相关标签:
1条回答
  • 2021-01-07 11:26

    I have a pdf in the raw folder and I am trying to open it in a webview using "https://drive.google.com/viewerng/viewer?embedded=true&url=" to open it in the webview.

    That has never been possible.

    Is there a better way to load a local pdf inside my app without having it take up the entire activity page?

    The best thing is to not load it inside your app at all. Use the user's preferred PDF viewing app, via ACTION_VIEW.

    Beyond that, you could use a slightly modified version of PDF.js on Android 4.4+. Or, use AndroidPdfViewer on a wider range of Android versions, though it makes your APK a lot bigger. See this blog post for more context on these and other (worse) options.

    Also, here are sample apps demonstrating:

    • PDF.js: https://github.com/commonsguy/cw-omnibus/tree/v8.10/PDF/PdfJS
    • AndroidPdfViewer: https://github.com/commonsguy/cw-omnibus/tree/v8.10/PDF/Pdfium
    0 讨论(0)
提交回复
热议问题