0

I see in "object library" pdfView is there, but, when I click on .XIB it got disappers.How can I use this for iPhone or IPad development? Plaese provide me any example links.Thanks.

Note: Plaese do not tell me to use any 3rd party lib,because I'm already refering two.This i don't want ot use going forword.

bapi
  • 1,903
  • 10
  • 34
  • 59

2 Answers2

1

PDFView is only for cocoa(OSX) not for iOS.

A PDFView object encapsulates the functionality of PDF Kit into a single widget that you can add to your application

PDFKit only available in OSX.

In iOS to display pdf pages you don't want use any third party libraries, you can draw the pdf view by creating a custom view override the draw something like

Get the pdf document

  NSString *pathToPdfDoc = [[NSBundle mainBundle] pathForResource:@"aa" ofType:@"pdf"];
  NSURL *pdfUrl = [NSURL fileURLWithPath:pathToPdfDoc];
  document = CGPDFDocumentCreateWithURL((CFURLRef)pdfUrl);
  currentPage = 1;     

In drawRect

-(void)drawRect:(CGRect)rect
{
    CGPDFPageRef page = CGPDFDocumentGetPage(document, currentPage);
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGContextSaveGState(ctx);
    CGContextTranslateCTM(ctx, 0.0, [self bounds].size.height);
    CGContextScaleCTM(ctx, 1.0, -1.0);
    CGContextConcatCTM(ctx, CGPDFPageGetDrawingTransform(page, kCGPDFCropBox, [self bounds], 0, true));
    CGContextDrawPDFPage(ctx, page);    
    CGContextRestoreGState(ctx);
}
Anil Varghese
  • 42,757
  • 9
  • 93
  • 110
  • Thanks for your answer.If its for OSX, then How to add PDF kit and use its functionality to show a pDF document in iPAD or iPhone.Could you plaese post some detail code or give a link to refer.What is document ? and what is current page?? Plaese give some details. – bapi Nov 08 '13 at 13:19
  • Create a custom view(Subclass of UIView) and do like as i said. If you are not getting let me know. – Anil Varghese Nov 08 '13 at 13:28
0

Are you posting two questions that are pretty much the same?

A couple of minutes ago you posted this: Object library not visible when click on .XIB in xcode ios

My answer still stands, you have chosen a OSX xib NOT an iOS xib.

If you want to show a PDF in an iOS app, you could add it to a UIWebView. Have a look at this question for details: iPhone : can we open pdf file using UIWebView?

Community
  • 1
  • 1
Mikael
  • 3,572
  • 1
  • 30
  • 43
  • I tried that, but some how its not working for me...Could you plaese post any tutorial for this?? – bapi Nov 08 '13 at 13:26
  • updated my answer. There is a link to a question describing on how to show a PDF in a UIWebView. Or you could have a look at the answer from Anil. – Mikael Nov 08 '13 at 13:30