banner
李大仁博客

李大仁博客

天地虽大,但有一念向善,心存良知,虽凡夫俗子,皆可为圣贤。

[Android]使用浏览器直接打开PDF和Office文档

Android 原生系统中的自带浏览器和 Chrome 浏览器是不支持直接打开 PDF 的文档的,需要现下载到本地之后再使用 Adobe Reader 之类的 PDF 阅读器才能打开。微软 Office 中 DOC 和 XLS 之类的也是如此。不过用习惯了安装了 ActiveX 插件的 IE 的客户最近突发奇想,要求在新开发 APP 中可以直接打开并阅读 PDF 和微软 Office 的 DOC,XLS,PPT 等文档。经过调查发现以下方法可用。供大家参考。

1. 使用内置 WebView 或 WebChromeClient 打开以下格式的 URL,借用 GoogleDoc 的嵌入式文档服务打开需要的打开的文档。只需按固定格式打开即可。 https://docs.google.com/gview?embedded=true&url=XXXXXX 其中 XXXXXX 为需要打开文档的公网 URL 地址

使用示例: https://docs.google.com/gview?embedded=true&url=https://contents.netbk.co.jp/pc/pdf/pr/20150130_fs.pdf

Google Doc 支持的文档格式众多 ,以下是支持的格式列表,完全可以满足在线浏览文档的需求。

Adobe Acrobat (PDF) Microsoft Word (DOC/DOCX*) Microsoft PowerPoint (PPT/PPTX*) Microsoft Excel (XLS/XLSX*) TIFF Images (TIF, TIFF) Apple Pages (PAGES) Adobe Illustrator (AI) Adobe Photoshop (PSD) Autodesk AutoCad (DXF) Scalable Vector Graphics (SVG) PostScript (EPS/PS) OpenType/TrueType Fonts (OTF, TTF) XML Paper Specification (XPS) Archive Files (ZIP/RAR)

考虑到国内 Google Doc 大部分情况下被封,国内用户使用可不是那么方便了。

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.