Skip to content

Opening pdf files in iPhone App

November 23, 2010

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

From → iPad, iPhone

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: