[英]How to save PDF file in iPhone device through application
Currently, I am working on create PDF file, saving it and retrieving file in UIWebview to display through iPhone application.But,Now I want to save PDF file in iPhone device like in NewsStand or iBooks.Is it possible to save PDF file in device? 目前,我正在创建PDF文件,将其保存并在UIWebview中检索文件以通过iPhone应用程序显示。但是,现在,我想将PDF文件保存在iPhone设备中,例如NewsStand或iBooks。是否可以将PDF文件保存在设备中? So that, I can open PDF file without opening an application.
这样一来,我无需打开应用程序即可打开PDF文件。 Please give me some idea.Thanks in advance.
请给我一些想法。谢谢。
Try this code: 试试这个代码:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSArray *pdfs = [[NSBundle bundleWithPath:[paths objectAtIndex:0]] pathsForResourcesOfType:@"pdf" inDirectory:nil];
Hope this helps. 希望这可以帮助。 Thanks.
谢谢。
This answer is already posted by many. 许多人已经发布了这个答案。 You can Save PDF content which is the URL format like below code
您可以保存PDF内容,它是URL格式,如下面的代码
NSData *savedPDFFile = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"pdf_url"]];
[savedPDFFile writeToFile:[NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], @"savedpdffilename.pdf"] atomically:YES];
Hope it helps you...! 希望它可以帮助您...!
For sending PDF File
use send-bundled-pdf-to-ibooks-from-within-app . 要发送
PDF File
使用send-bundled-pdf-to-ibooks-from-within-app 。 Same is for newsstand
. newsstand
。 Note : Firstly save PDF File
in directory
then use the path
to share
注意 :首先将
PDF File
保存在directory
然后使用该path
share
For displaying PDF
in own application
user apple's QLPreviewController
. 为了在自己的
application
displaying PDF
,用户必须使用Apple的QLPreviewController
。 check sample code 检查样本代码
Other third party
for free
for displaying PDF
is : 其他
free
displaying PDF
third party
是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.