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];

 }

Advertisements