views:

634

answers:

2

Hi All,

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

+3  A: 

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

Paul Betts
+4  A: 

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.

Quinn Taylor
-1: See http://developer.apple.com/iphone/library/qa/qa2008/qa1630.html for a list of supported formats
Alex Reynolds