2

I've a a pdf placed in my Code files. I want it to open in iBooks, while researching I've found this :

NSString *stringURL = @"itms-books:";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

NSString *stringURL = @"itms-bookss:";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

How can I use this or what other way i can open my PDF File in iBook? Regards

Ekta Padaliya
  • 5,743
  • 3
  • 39
  • 51
Muhammad Umar
  • 11,391
  • 21
  • 91
  • 193
  • Hi Muhammad, Have you solved the problem yet? I encounter the same problem right now. Appreciate if you can share with me your findings. Thanks in advance. – Bowie Feb 14 '13 at 04:33
  • Hello, Have eyou solved this issue.. Can you able to open iBooks directly from your app with pdf data / path... – Easwaramoorthy Kanagaraj Sep 05 '13 at 14:42

3 Answers3

3

Maybe too late but I created a small example where the method explained in andycodes used. I uploaded to Github and you can download it here:

https://github.com/cjimenezpacho/openpdfibooks

Basically is this piece of code in a IBAction and the required delegate methods:

NSURL *url = [[NSBundle mainBundle]
URLForResource: @"iPhoneintro" withExtension:@"pdf"];
self.docController = [UIDocumentInteractionController interactionControllerWithURL:url];
self.docController.delegate = self;
[self.docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];

Links to Apple documentation:

Class: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDocumentInteractionController_class/Reference/Reference.html

Ekta Padaliya
  • 5,743
  • 3
  • 39
  • 51
Carlos Jiménez
  • 527
  • 5
  • 15
0
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"itms-bookss://%@",self.pathToFile]]]; 

this does open a local pdf to Ibooks needs 2 s's.

Edit: to be specific on this this will open the local PDF if it is in iBooks already locally on the device.

if you need to add it to iBooks so far as I know you need to use the UIDocumentInteractionController.

Pascale Beaulac
  • 889
  • 10
  • 28
-1

Take a look at this Tumblr post explaining how do achieve a similar result using UIDocumentInteractionControllers.

http://andycodes.tumblr.com/post/738375724/ios4-sdk-opening-pdfs-in-ibooks

Alex Stuckey
  • 1,250
  • 1
  • 14
  • 28
  • I NEEd to make it open only in iBooks not show a list of all available apps which can open it – Muhammad Umar Jan 30 '13 at 20:44
  • There is an unofficial URL protocol that can send them directly to iBooks, but since it is unofficial your app may be rejected for using it. – Alex Stuckey Jan 30 '13 at 22:56
  • @AlexStuckey So do you mean that if we use books:// Url Schemes, app will be rejected. Are you sure? – Easwaramoorthy Kanagaraj Sep 05 '13 at 14:40
  • @EaswaramoorthyKanagaraj it's been a while since I've looked at this so I'm not too sure specifically about iBooks. But if you are using any undocumented API you are liable to be rejected from the App Store and/or have functionality broken in the future. – Alex Stuckey Sep 05 '13 at 19:22
  • @AlexStuckey Thanks for your reply. I think ibooks schema is undefined. But let me bug it for a while and let you know. – Easwaramoorthy Kanagaraj Sep 06 '13 at 04:38