How can I open a PDF file that was stored in my iPad/iPhone, using my own application?
Asked
Active
Viewed 8,945 times
3
-
Did you search before asking question?? – rohan-patel Mar 13 '12 at 08:49
-
Possible duplicate : http://stackoverflow.com/questions/6983502/iphone-opening-word-and-excel-file-without-using-uiwebview – rohan-patel Mar 13 '12 at 08:53
-
3"How can I open a PDF file..." is hardly a duplicate of "opening word and excel file" :-) – Rok Jarc Mar 13 '12 at 09:16
3 Answers
6
-
My pdf file is not in my application bundle eventhough can we open it?? – Monish Kumar Mar 13 '12 at 08:41
-
-
1
-
-
2
There is a good tutorial available here which demonstrates how to open .pdf, .xls files in your application.
The main class you have to refer for this is QLPreviewController. here
This is the Datasource Method you would have to call for that
- (id <QLPreviewItem>)previewController: (QLPreviewController *)controller previewItemAtIndex:(NSInteger)index
{
// Break the path into it's components (filename and extension)
NSArray *fileComponents = [[arrayOfDocuments objectAtIndex: index] componentsSeparatedByString:@"."];
// Use the filename (index 0) and the extension (index 1) to get path
NSString *path = [[NSBundle mainBundle] pathForResource:[fileComponents objectAtIndex:0] ofType:[fileComponents objectAtIndex:1]];
return [NSURL fileURLWithPath:path];
}
Also someone would like to refer this SO question :iPhone - Opening word and excel file without using UIWebview.
Community
- 1
- 1
rohan-patel
- 5,772
- 5
- 45
- 68
-
Is this opens the pdf files which are not in my app's bundle but it was in ipad? – Monish Kumar Mar 13 '12 at 08:51
-
@anonymous, now you are answering even after getting upset from Monish... Dear 'anonymous', this is a community and you should be more polite with your words. Everyone comes here to learn and share their knowledge.. – Saurabh Passolia Mar 13 '12 at 08:57
-
@samfisher : Yes mate..I totally agree that we have to be polite. But I answered for the sake of this community. This answer is for those people who really care to search for a solution and by chance they click here they do not go without getting an answer.. – rohan-patel Mar 13 '12 at 09:52