Reputation: 337
How to download a PDF file when a button is clicked?
Upvotes: 1
Views: 7559
Reputation: 1365
Check out these posts:
iPhone : can we open pdf file using UIWebView?
Display PDF in UIWebView using loadData
How do I make UIWebView show a pdf file from its own app?
Basically, you save the pdf to your sandbox and then use a UIWebview to open the pdf and display it to the user. The posts above have a ton of sample code for you to check out and should get you started. Good luck!
UPDATE
also check out: How to download PDF and store it locally on iPhone?
This post has a bit about saving pdf's from an URL to disk. One thing I would add to this post is to NOT download a file in the main thread but rather save it in another thread.
EXPLORING THE APP SANDBOX
In response to the comment below: You can explore the application documents using the mac terminal application. If you have the application installed on the iPhone simulator use terminal to look through the contents of the sandbox. The path to your application will be something like: ~/Library/Application Support/iPhone Simulator/user/Applications/<GUID>
Check out this Apple Doc for how the filesystem works for iOS and for more information about where to store your application data: http://developer.apple.com/library/mac/#documentation/FileManagement/Conceptual/FileSystemProgrammingGUide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW2
Upvotes: 3