-1

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267

4 Answers4

1

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];
quaertym
  • 3,917
  • 2
  • 29
  • 41
1

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.

DIJ
  • 347
  • 4
  • 19
0

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?

CGPDF iPhone/iPad memory problems

Get PDF hyperlinks on iOS with Quartz

Community
  • 1
  • 1
ySgPjx
  • 10,165
  • 7
  • 61
  • 78
0

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.

Github PDF test

Peter O.
  • 32,158
  • 14
  • 82
  • 96
MrStark
  • 26
  • 4