Android 原生支持预览PDF文件等文档?
Android native support for previewing PDF files and other documents?
快速版:
Android中是否有原生的class,类似于iOS中的WKWebView
,可以显示Word文档和PDF?
长版:
我正在努力将我们的混合应用程序的本机包装器部分移植到 Android。在 iOS 中,我可以使用 WKWebView
来显示各种文档的预览,特别是 Word (.docx) 文档和 PDF 文件。
使用查看意图,我可以 Android 在 Adobe 的查看器中打开 PDF,但在安装之前,我只是遇到一个异常,即无法找到用于查看文件类型的应用程序. Android 中真的没有对如此常见的东西的原生支持吗?我 phone 上的文件应用程序(我可以在其中查看下载等)可以打开和显示 PDF,但显然没有在操作系统中注册这一事实。
Is there a native class in Android, similar to WKWebView on iOS, that can show Word documents and PDFs?
如果 "native class" 你的意思是 "a Java class built into the Android SDK",答案是 "not really"。 DOCX 没有任何内容。 Android 5.0+ 有一个 PdfRenderer
,但它是为使用 Android 的打印框架生成的 PDF 的打印预览而设计的,将无法呈现许多任意 PDF。
In iOS I can use WKWebView as a way to display previews of various kinds of documents, including specifically Word (.docx) documents and PDF files.
有开源库和商业库提供此功能。我 blogged about some open source PDF-rendering options 2017 年初
Using view intents I can get Android to open a PDF in Adobe's viewer, but before installing that I'd just get an exception to the effect that an app to view the file type could not be found.
这与"a native class"无关。 Intent
由应用程序及其注册组件(在您的情况下为活动)处理。
目前,Android 开源项目 (AOSP) 中没有任何应用程序是 PDF 查看器或其他文档格式的查看器。任何给定设备是否有一个(例如,Google 文档)会有所不同。
Is there really no native support in Android for something so common?
在应用程序方面,没有要求设备制造商预装 PDF 查看器或 DOCX 查看器。即使他们有,也不需要这些查看器的开发人员注册支持您使用的任何 Intent
结构的 <intent-filter>
。由于您的 Intent
不在您的问题中,因此我们无法真正评论对 Intent
.
的支持有多常见或不常见。
快速版:
Android中是否有原生的class,类似于iOS中的WKWebView
,可以显示Word文档和PDF?
长版:
我正在努力将我们的混合应用程序的本机包装器部分移植到 Android。在 iOS 中,我可以使用 WKWebView
来显示各种文档的预览,特别是 Word (.docx) 文档和 PDF 文件。
使用查看意图,我可以 Android 在 Adobe 的查看器中打开 PDF,但在安装之前,我只是遇到一个异常,即无法找到用于查看文件类型的应用程序. Android 中真的没有对如此常见的东西的原生支持吗?我 phone 上的文件应用程序(我可以在其中查看下载等)可以打开和显示 PDF,但显然没有在操作系统中注册这一事实。
Is there a native class in Android, similar to WKWebView on iOS, that can show Word documents and PDFs?
如果 "native class" 你的意思是 "a Java class built into the Android SDK",答案是 "not really"。 DOCX 没有任何内容。 Android 5.0+ 有一个 PdfRenderer
,但它是为使用 Android 的打印框架生成的 PDF 的打印预览而设计的,将无法呈现许多任意 PDF。
In iOS I can use WKWebView as a way to display previews of various kinds of documents, including specifically Word (.docx) documents and PDF files.
有开源库和商业库提供此功能。我 blogged about some open source PDF-rendering options 2017 年初
Using view intents I can get Android to open a PDF in Adobe's viewer, but before installing that I'd just get an exception to the effect that an app to view the file type could not be found.
这与"a native class"无关。 Intent
由应用程序及其注册组件(在您的情况下为活动)处理。
目前,Android 开源项目 (AOSP) 中没有任何应用程序是 PDF 查看器或其他文档格式的查看器。任何给定设备是否有一个(例如,Google 文档)会有所不同。
Is there really no native support in Android for something so common?
在应用程序方面,没有要求设备制造商预装 PDF 查看器或 DOCX 查看器。即使他们有,也不需要这些查看器的开发人员注册支持您使用的任何 Intent
结构的 <intent-filter>
。由于您的 Intent
不在您的问题中,因此我们无法真正评论对 Intent
.