views:

30

answers:

2

is UIWebView the only way to open a pdf document on the iphone? how can i interact with the document? eg: getting the current page number?

A: 

It's not the only way. There's a whole toolkit built in which lets you render PDF pages to a UIView. Check out:

  • CGPDFDocumentCreateWithURL
  • CGPDFDocumentGetNumberOfPages
  • CGPDFDocumentGetPage
  • CGContextDrawPDFPage

to name a few (core graphics) functions that relate to PDF rendering.

Kalle
A: 

You should read the Apple documentation about Drawing with quartz 2d. There's a section just about handling with PDF documents. If you don't like to show a PDF in a UIWebView, you create your own view. Just subclass UIView and overwrite the method -(void)drawRect:(CGRect)rect for your custom drawing. Create a CGContextRef a draw your PDF directly in that context using the specific function of core graphics. Core Graphics provides a lot of other functions for PDF documents, like Kalle already mentioned.

If you're not really used to core graphics, it's really difficult sometimes and you probably need a lot time to get used to it, so I recommend using UIWebView to display a PDF. It relatively simple.

burki
do you have a link to apple's documentation page?
Janie
http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction/Introduction.html
burki