Reputation: 1941
What is the way to read PDF content on an iPad or iPhone?
Upvotes: 4
Views: 4403
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
Reputation: 1396
There is another simple way to read a PDF in iPhone/iPad:
Take one UIwebView (name:pdfView).
Give Iboutlet connection to it & Delegate it to FilesOwner
In Viewdidload/VIewWillApper/VIewDidApper
[self.pdfView loadRequest:[NSURLRequest requestWithURL:
[NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"ObjC" ofType:@"pdf"]]]];
ObjC.pdf
should be in resource folder
Upvotes: 3
Reputation: 7176
You can use Quartz to parse a PDF document and extract the metadata. Parsing a PDF
Upvotes: 7