2014-06-09 40 views
0

目前,我正在创建PDF文件,将其保存并在UIWebview中检索文件以通过iPhone应用程序显示。但是,现在我想将PDF文件保存在iPhone设备中NewsStand或iBooks.Is是否可以将PDF文件保存在设备中?所以,我可以在不打开应用程序的情况下打开PDF文件。 请给我一些idea.Thanks提前。如何通过应用程序在iPhone设备上保存PDF文件

+0

我没有试过,但是这可能对您有用: http://andycodes.tumblr.com/post/738375724/ios4-sdk-opening-pdfs-in- ibooks的 – Shrejas

回答

0

试试这个代码:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSArray *pdfs = [[NSBundle bundleWithPath:[paths objectAtIndex:0]] pathsForResourcesOfType:@"pdf" inDirectory:nil]; 

希望这有助于。谢谢。

0

这个答案已经被很多人发表了。您可以保存PDF格式的内容,其格式如下代码

NSData *savedPDFFile = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"pdf_url"]]; 
[savedPDFFile writeToFile:[NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], @"savedpdffilename.pdf"] atomically:YES]; 

希望它可以帮助你......!

0

用于发送PDF File使用send-bundled-pdf-to-ibooks-from-within-app。同样适用于newsstand注意:首先保存PDF Filedirectory然后使用自己在用户application苹果的QLPreviewControllerpathshare

displaying PDF。检查sample code

其他third partyfreedisplaying PDF是:

  1. Reader
  2. FastPDFKit注意:免费版availbale
相关问题