TechBee
TechBee

Reputation: 1941

How to read a pdf on ipad/iphone?

What is the way to read PDF content on an iPad or iPhone?

Upvotes: 4

Views: 4403

Answers (4)

Himanshu Mahajan
Himanshu Mahajan

Reputation: 4799

Firstly, save a built in pdf file in document Directory of iPhone Simulator (say it demo.pdf). then use following code in ViewController.m file at ViewDidLoad method and dont forget to add UIWebViewDelegate in ViewController.h file

    -(void) viewDidLoad
    {
           [super viewDidLoad];
           UIWebView theWebView=[[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
           theWebView.delegate=self;
           theWebView.scalesPageToFit=YES;
           [self.view addSubview:theWebView];

           NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
           NSString *documentDir=[paths objectAtIndex:0];
           NSString *fileName=[documentDir stringByAppendingPathComponent:@"demo.pdf"];
           NSURL *url=[NSURL fileURLWithPath:fileName];
           [theWebView loadRequest:[NSURLRequest requestWithURL:url]];
     }

Upvotes: 0

Archana Chaurasia
Archana Chaurasia

Reputation: 1396

There is another simple way to read a PDF in iPhone/iPad:

  1. Take one UIwebView (name:pdfView).

  2. Give Iboutlet connection to it & Delegate it to FilesOwner

  3. In Viewdidload/VIewWillApper/VIewDidApper

    [self.pdfView loadRequest:[NSURLRequest requestWithURL:
    [NSURL fileURLWithPath:[[NSBundle mainBundle] 
    pathForResource:@"ObjC" ofType:@"pdf"]]]];
    
  4. ObjC.pdf should be in resource folder

Upvotes: 3

meersmans
meersmans

Reputation: 463

Use fastpdfkit: https://github.com/mobfarm/FastPdfKit

Upvotes: 1

davbryn
davbryn

Reputation: 7176

You can use Quartz to parse a PDF document and extract the metadata. Parsing a PDF

Upvotes: 7

Related Questions