I created an app that generates a PDF and saves it to the NSDocumentDirectory. I want to make it very easy for the user to locate the file and display it or print it using their iPhone. How do I find this file and view it easily?
Here is the code I used to create the PDF:
//USE PDFGENERATOR TO CREATE A PDF FILE
PDFViewController* pdf = [[PDFViewController alloc] init];
NSString *header = lblTitle.text;
NSLog(@"fullQuote=%@", header);
NSString *body = [NSString stringWithFormat:@"%@ \n\n - LRH \n %@", lblExcerpt.text, lblDesc2.text];
NSLog(@"fullQuote=%@", body);
pageSize = CGSizeMake(612, 792);
NSString *fileName = [NSString stringWithFormat:@"%@.pdf", lblTitle.text];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *pdfFileName = [documentsDirectory stringByAppendingPathComponent:fileName];
[pdf generatePdf :pdfFileName:header:body:nil];
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. hereThis is the Datasource Method you would have to call for that
Also someone would like to refer this SO question :iPhone – Opening word and excel file without using UIWebview.