更新时间:2023-01-30 16:55:25
我在原始文件夹中有一个pdf文件,我正在尝试使用" https://drive.google.com/viewerng/viewer?embedded=true&url= "以在网络视图中将其打开.
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.
那是不可能的.
有没有更好的方法可以在我的应用程序内部加载本地pdf文件而不占用整个活动页面?
Is there a better way to load a local pdf inside my app without having it take up the entire activity page?
***的是根本不将其加载到您的应用程序中.通过ACTION_VIEW
使用用户喜欢的PDF查看应用程序.
The best thing is to not load it inside your app at all. Use the user's preferred PDF viewing app, via ACTION_VIEW
.
除此之外,您还可以在Android上使用 PDF.js 的稍作修改的版本4.4+.或者,在更广泛的Android版本上使用AndroidPdfViewer
,尽管它会使您的APK更大.请参阅此博客文章,以获取有关这些内容的更多信息,以及其他(更糟糕的)选项.
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 PDF.js
: https://github.com/commonsguy/cw-omnibus/tree/v8.10/PDF/PdfJSAndroidPdfViewer
: https://github.com/commonsguy/cw-omnibus/tree/v8.10/PDF/Pdfium