-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
  • 34,719
  • 24
  • 185
  • 251

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,757
  • 2
  • 27
  • 39
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
  • 259
  • 3
  • 18
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
  • 9,953
  • 7
  • 57
  • 77
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.
  • 30,765
  • 14
  • 76
  • 91
MrStark
  • 26
  • 4