【iOS_GitHub】文档/文件查看器(支持本地或者其他app分享过来的word、excel、pdf、rtf等格式文件)
2016-09-07 16:31
1136 查看
DocViewer(文档/文件查看器)
Function Description
文档查看器(Word && Excel && PDF && Rft || Network && Local || self && other App)文件共享 && 查看 (Network && Local)
how to use
1. 相关参数配置
a. JhtLoadDocViewParamModel:文本加载 View 配置ModelJhtLoadDocView内部相关属性的修改可通过修改此model实现
b. JhtDocFileOperations:文件操作类
文件保存 && 清理等方法
c. JhtShowDumpingViewParamModel:下滑提示框配置参数model
用于设置提示框中的 文字的大小,颜色,位置,背景图,是否包含警示小图标等参数
d. JhtFileModel:下载文档的Model
用于设置文件ID,文件名,绝对路径(本地文件),文件大小等参数
2. DocListViewController:文档列表
tableView的数据源是一个装有model的数组,model根据属性fileAbsolutePath(本地绝对路径),判断是否需要下载
3. LoadDocViewController:文档详情VC,内部使用JhtLoadDocView
4. JhtLoadDocView:文本加载 View
a. 如果不需要下载,通过webView直接显示b. 需要下载,则通过JhtDownloadRequest函数中的类方法进行下载,暂停等操作(注意:JhtFileModel属性:fileSize,应写成这种式“KB,MB,GB,Bytes”,为了计算手机剩余内存,关系是否能下载成功
c. 资源共享
《JhtDocViewer》文件用”其他应用“打开
“其他应用”文件用《JhtDocViewer》打开
d. 无网络弹框
具体使用详见demo
needed to pay attention
1. 如果我们在iOS9下直接进行HTTP请求是会收到如下错误提示
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
系统会告诉我们不能直接使用HTTP进行请求,需要在Info.plist新增一段用于控制ATS的配置
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
即:
2. 如果想共享自己app的文档查看功能,需在info.plist 中添加如下信息
<key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeIconFiles</key> <array> <string>MySmallIcon.png</string> <string>MyLargeIcon.png</string> </array> <key>CFBundleTypeName</key> <string>My File Format</string> <key>LSHandlerRank</key> <string>Owner</string> <key>LSItemContentTypes</key> <array> <string>com.microsoft.powerpoint.ppt</string> <string>public.item</string> <string>com.microsoft.word.doc</string> <string>com.adobe.pdf</string> <string>com.microsoft.excel.xls</string> <string>public.image</string> <string>public.content</string> <string>public.composite-content</string> <string>public.archive</string> <string>public.audio</string> <string>public.movie</string> <string>public.text</string> <string>public.data</string> </array> </dict> </array>
属性说明:
* CFBundleTypeName:文档的类型名称
* LSHandlerRank:这里指是否拥有子文档
3. info.plist 中,对应Localization native development region键值 加入Chinese
4. 在第三方调用我们的APP后,会调用如下方法
- (BOOL)application:(UIApplication *)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary<NSString *,id> *)options { if (options) { NSString *str = [NSString stringWithFormat:@"\n发送请求的应用程序的 Bundle ID:%@\n\n文件的NSURL:%@", options[UIApplicationOpenURLOptionsSourceApplicationKey], url]; NSLog(@"%@", str); if (self.window && url) { // 根据“其他应用” 用“本应用”打开,通过url,进入列表页 [self pushDocListViewControllerWithUrl:url]; } } return YES; } #pragma mark ApplicationDelegate Method /** 根据“其他应用” 用“本应用”打开,通过url,进入列表页 */ - (void)pushDocListViewControllerWithUrl:(NSURL *)url { // 根据“其他应用” 用“本应用”打开,通过要打开的url,获得本地地址 NSString *appFilePath = [[JhtDocFileOperations sharedInstance] findLocalPathFromAppLicationOpenUrl:url]; // 跳转页面 DocListViewController *doc = [[DocListViewController alloc] init]; doc.appFilePath = appFilePath; [_nav pushViewController:doc animated:YES]; }
5. 库文件
系统库:WebKit.framework <br> 三方库:AFNetworking3.x <br>
相关文章推荐
- IOS 打开预览pdf、ppt、excel、word、tet、rtf、csv格式的文件,微信文件分享
- iOS上---预览本地ppt,word ,excel,pdf文件
- 支持Word文档和其他文件格式间的转换的控件Spire.Doc for .NET
- ASP.NET Core2集成Office Online Server(OWAS)实现办公文档的在线预览与编辑(支持word\excel\ppt\pdf等格式)
- JAVA读取WORD,EXCEL,PDF,TXT,RTF,HTML文件文本内容的方法示例
- 类似百度文库在线预览文档flash版(支持word、excel、ppt、pdf)+在线预览文档html版
- Java程序员从笨鸟到菜鸟之(一百零三)java操作office和pdf文件(一)java读取word,excel和pdf文档内容
- 类似百度文库在线预览文档flash版(支持word、excel、ppt、pdf)+在线预览文档html版
- Java程序员从笨鸟到菜鸟之(一百零三)java操作office和pdf文件(一)java读取word,excel和pdf文档内容
- PDF文件转换成Word或者Excel的网站,免费的!!
- c#实现word,excel转pdf代码及部分Office 2007文件格式转换为xps和pdf代码整理
- JAVA读取WORD,EXCEL,PDF,TXT,RTF,HTML文件文本内容的方法
- C#将文档(Word\ Excel\ PowerPoint\ Visio\ text\ XML\ RTF\ CSV )转成Pdf
- 类似百度文库在线预览文档flash版(支持word、excel、ppt、pdf)+在线预览文档html版
- C#对word、excel、pdf等格式文件的操作总结
- NPOI 创建 Excel 出错“此文件中的某些文本格式可能已经更改,因为它已经超出最多允许的字体数。关闭其他文档再试一次可能有用。”
- JAVA读取WORD,EXCEL,PDF,TXT,RTF,HTML文件文本内容的方法示例
- JAVA读取WORD,EXCEL,PDF,TXT,RTF,HTML文件文本内容的方法示例
- 类似百度文库在线预览文档flash版(支持word、excel、ppt、pdf)+在线预览文档html版
- JAVA读取WORD,EXCEL,PDF,TXT,RTF,HTML文件文本内容的方法示例