7

I really need to make a UIWebView open up a specific PDF document that is in my project directory. I can't seem to find any tutorials on this. I found one, but the author was not specific about some of the code.

I have to assume it's got to be quite a simple bit of code.

Can someone help me code UIWebView to load a PDF?

Thanks.

Aakburns
  • 307
  • 1
  • 5
  • 19
  • How can we merge this with http://stackoverflow.com/questions/272132/how-to-use-the-iphones-built-in-pdf-viewer-to-display-a-document. This has better answer too. – bentford Jun 29 '11 at 03:36

1 Answers1

13

Use pathForResource and fileURLWithPath:

NSString *path = [[NSBundle mainBundle] pathForResource:@"FileNameHere" 
                                                 ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];