Now iBooks supports PDF. My app has access to many PDF files. Is it possible to send PDFs to iBooks (or other PDF readers like GoodReader and iAnnotate PDF) from my app?
Asked
Active
Viewed 9,524 times
3 Answers
11
//get path to file you want to open
NSString *fileToOpen = [[NSBundle mainBundle] pathForResource:@"readme" ofType:@"pdf"];
//create NSURL to that path
NSURL *url = [NSURL fileURLWithPath:fileToOpen];
//use the UIDocInteractionController API to get list of devices that support the file type
docController = [UIDocumentInteractionController interactionControllerWithURL:url];
[docController retain];
//present a drop down list of the apps that support the file type, click an item in the list will open that app while passing in the file.
BOOL isValid = [docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];

Felipe Cypriano
- 2,727
- 22
- 32

AndroidUser
- 187
- 1
- 4
-
2Only thing I would add, is this does not work in simulator. You have to test on hardware. Thanks for the post. – Louie May 31 '11 at 05:08
-
@Louie ty for that. I couldn't figure out what is going on. – jrwren Jan 06 '12 at 16:41
2
To answer my own question - yes, you can send a PDF to apps supporting custom URL scheme using this:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
URL scheme for GoodReader is:
url=@"ghttp://www.mysite.com/myfile.pdf";
iAnnotate PDF is:
url=@"pdfs://www.mysite.com/myfile.pdf";
Does anyone know the custom URL scheme for iBooks?

user373789
- 81
- 1
- 3
0
Use this link to find the url schemes http://schemes.zwapp.com/
and use [[UIApplication sharedApplication] openURL:url];
to launch in that application.
thanks

Naveen Shan
- 9,192
- 3
- 29
- 43