简体   繁体   English

如何通过应用程序将PDF文件保存在iPhone设备中

[英]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是:

  1. Reader 读者
  2. FastPDFKit . FastPDFKit Note : Free version availbale 注意 :免费版本可用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将pdf和视频文件保存到设备文件系统,而不是应用程序目录 - How to save pdf and videos file to device file system, NOT application directory 如何在不同的选项(如iBook,Go Daddy等)中打开Pdf文件并将其保存在iPhone设备中? - How to open Pdf file in different option like as iBook ,Go Daddy etc and save there in iPhone device? 将pdf文件保存在设备中 - save pdf file in device 如何在iPhone应用程序中从SkyDrive保存和检索下载的pdf文件 - How to save and retrieve downloaded pdf files from skydrive in iphone application 如何将pdf文件保存在iPhone内存中,并使用Titanium通过pdf文件打开器应用程序进行访问 - How to save a pdf file in iPhone memory and make it accessible by pdf file opener applications using titanium 当我们在iPhone中打开pdf时,如何在iPhone中保存该pdf - When we open pdf in iPhone then how to save this pdf in iphone 如何在iPhone中查找Pdf文件 - How to find Pdf file in iPhone 如何使用 swift 从 iphone 设备上传文件 Doc/pdf/excel 到后端? - How to Upload file Doc/pdf/excel from iphone device into the backend using swift? 以编程方式在iPhone中保存PDF - Programatically save a PDF in the iPhone 就像我能够通过ibook来浏览pdf文件一样,如何从我的iPhone来浏览我的app的pdf文件? - How to browse pdf file from my iphone for my app, just like I am able to browse pdf file through ibooks?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM