Reading .ppt (MS PowerPoint) file in Cocoa Touch

我是研究僧i 提交于 2019-12-12 10:43:45

问题


Any idea how to read a .ppt file in Cocoa Touch ?

I tried to load the contents of the file in UIWebView but it didn't work. Here is the code :

[aWebView loadData:[NSData dataWithContentsOfFile:filePath]
          MIMEType:@"application/vnd.ms-powerpoint"
  textEncodingName:@"utf-8"
           baseURL:[NSURL fileURLWithPath:filePath]];

[powerWeb loadData:[NSData dataWithContentsOfFile:filePath]
          MIMEType:@"application/vnd.ms-powerpoint"
  textEncodingName:@"utf-8"
           baseURL:[NSURL fileURLWithPath:filePath]]; 

All suggestions are highly appreciated.

Thanks


回答1:


UIWebView is for displaying web content, in a format you could view directly in a browser. It has no idea about how to display PowerPoint files — most applications don't, since it's a proprietary Microsoft format. (I stand corrected — apparently, UIWebView does know how to display PowerPoint files and others. If it's not working, I'd suggest trying a different MIME type, such as application/mspowerpoint.) Just remember that simply loading a file into an NSData doesn't mean that anyone else you pass that data to will know how to interpret the bytes.

You might check whether Microsoft offers any tools for parsing PPT files, or look around for open-source tools — for example, Google searches often convert to HTML. Just be aware that your browser is usually not loading a PowerPoint version of the file directly.




回答2:


If Webkit doesn't have a PPT parser, you're on your own - you have to manually load PPT files, parse them, and render them; it might be easiest to make a web service to do this (this way you get real libraries), then have them download the images over HTTP so the client-side implementation is simple




回答3:


NSString *powerPointFilePath = [[NSBundle mainBundle] pathForResource:@"myFile" ofType:@"ppt"];

NSURL *powerPointFileURL = [NSURL fileURLWithPath:powerPointFilePath];

[self.webView loadRequest:[NSURLRequest requestWithURL:powerPointFileURL]];


来源:https://stackoverflow.com/questions/1871494/reading-ppt-ms-powerpoint-file-in-cocoa-touch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!