1
我創建了一個生成PDF並將其保存到NSDocumentDirectory的應用程序。我想讓用戶很容易找到文件並顯示或使用iPhone打印。我如何找到該文件並輕鬆查看?如何從應用程序訪問保存到iPhone的PDF?
這裏是我用來創建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];
謝謝你,這是非常有幫助的。我還希望簡單指導如何查找文件,例如創建PDF的人員,現在想要在應用程序的外部查看它,或者以某種其他方式在文件系統上訪問文件。是甚至可能的嗎? – jroyce 2012-03-01 05:55:29