What is the way to read PDF content on an iPad or iPhone?
Asked
Active
Viewed 4,388 times
4
-
1possible duplicate of [Newbie wants to create a PDF reader for ipod touch - what's the best approach?](http://stackoverflow.com/questions/93297/newbie-wants-to-create-a-pdf-reader-for-ipod-touch-whats-the-best-approach) – Brad Larson Jul 16 '10 at 14:46
4 Answers
7
You can use Quartz to parse a PDF document and extract the metadata. Parsing a PDF
davbryn
- 7,156
- 2
- 24
- 47
3
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.pdfshould be in resource folder
Jeff Atwood
- 63,320
- 48
- 150
- 153
Archana Chaurasia
- 1,396
- 3
- 19
- 35
0
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]];
}
Himanshu Mahajan
- 4,779
- 2
- 36
- 29