Opening Doc, Excel, ppt files in iPhone, iPad

1 Comment

Once I figured out the way to open pdf files in iPhone and iPad, I was in a lookout for opening *.doc, *.xls, *.ppt files. Finally after a bit of digging, got to know it. Tried the same code in iPad, it did not work..I also tried opening Open Office document files and it did not work.

Here is the code for you.

NSString *path = [[NSBundle mainBundle] pathForResource:@"C.doc" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webview loadRequest:request];


Opening pdf files in iPhone App

Leave a comment

I was wondering how we can open pdf files in a iPhone app. And after a bit of digging developer’s reference, got to know how we can open the pdf files.

Here is the code . Grab it.

NSString *thePath = [[NSBundle mainBundle] pathForResource:@"Your File Name" ofType:@"pdf"];

 if (thePath) {

 NSData *pdfData = [NSData dataWithContentsOfFile:thePath];

 [webview loadData:pdfData MIMEType:@"application/pdf"

 textEncodingName:@"utf-8" baseURL:nil];