0

I have a pdf file in my iPad application. I want to save that pdf file on iPad so that I can read it out of my application. I am using the following path for save pdf file on iPad:-

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

 NSString *documentsDirectory = [paths objectAtIndex:0];

 NSString *fileBPath = [documentsDirectory stringByAppendingPathComponent:@"tmp.pdf"];

But I am not able to find this pdf file on my iPad. Can anyone suggest me how can I find it ?
Is file path wrong? then suggest me the file path for saving the pdf file ?

Thanks in Advance

Deepika
  • 3,382
  • 2
  • 17
  • 14

1 Answers1

2

1) See this SO question/answer regarding creation of a pdf from a UIView

2) If you already have the pdf file as an NSData object, you can save that to a file in your documents directory using

[NSData writeToFile:fileBPath atomically:YES];

3) On the other hand, if the PDF file is part of your application bundle (ie included with the app at compile time) it won't be in the documents directory.

Take a look at the documentation for [NSBundle mainBundle] -- that is where your PDF will be.

Community
  • 1
  • 1
TomH
  • 2,950
  • 2
  • 26
  • 49
  • I am creating a pdf from UIView in my application & I want to save that created pdf file on iPad. – Deepika Sep 22 '10 at 11:12
  • @Deepika I've updated my answer above. You have a few different options depending on how/if you have created the pdf – TomH Sep 22 '10 at 12:13
  • Pdf is successfully created on iPad....but I am not able to find the icon of that file on ipad so that I can read it directly. – Deepika Sep 27 '10 at 05:13
  • What do you mean by 'not able to find the icon'? – TomH Sep 27 '10 at 14:25
  • I mean to say that how can I open that file outside the application ? – Deepika Oct 01 '10 at 04:10
  • Good question. I don't know that you will be able to open the pdf from outside of your application. You *may* however be able to open the pdf with iBooks from within your app. iBooks registers itms-books: and itms-bookss: URL schemes so you *might* be able to open the pdf by constructing a URL with one of those schemas. – TomH Oct 01 '10 at 18:37
  • Here's another resource that may be helpful: UIDocumentInteractionController. http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIDocumentInteractionController_class/Reference/Reference.html – TomH Oct 06 '10 at 15:04