How can I create a pdf reader in iphone? It should open within the same framework of my application. I have got code for creating PDF files but nothing for viewing a PDF. can anyone help me on dis ground?
4 Answers
You can use UIWebView or Quartz to display PDFs.
For UIWebView use this:
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake( 0, 0, 320, 480 )];
NSString *path = [[NSBundle mainBundle] pathForResource:@"something" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[webView loadRequest:request];
webView.scalesPageToFit = YES;
[self.view addSubview:webView];
[webView release];

- 3,917
- 2
- 29
- 41
I'm currently building an app that uses a PDF document as will. There are 2 way's to display a pdf document, by far the simplest (but slowest) way is using a UIWebView.
The other option is building some sort of reader yourself by using the quartz2d libraries.
Apple has some good documentation on it: quart2d programming guide.
And an Example called zooming PDF Viewer.

- 347
- 4
- 19
Avoid WebViews, they are slow and you have no control over them.
The best way to render PDFs on iOS is using the CGPDF*
set of functions available with Quartz.
Be aware that it won't be super easy. Over time I have found and/or contributed to numerous questions on SO about PDFs on iPhone. Check those out:
Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints?
I have created a PDF renderer here from apple's code. Just swipe left or right to browse through pages, pinch to zoom etc.
Here is my github.