0

I have been searching for days for a solution to my problem and cant find exactly what I need. I have created an interactive PDF that needs to be viewed in Adobe Reader (the app is on the ipad). I have multiple view controllers I need to add a universal button to that will open Adobe Reader to show the pdf (via popover to the app or embedded, embedded preferred). Currently when i click my button, the screen just slightly dims, then goes back to normal after a second touch. Based on what im looking for, I am assuming this will be via an IBaction and I currently have the following:

h file:

#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UIDocumentInteractionControllerDelegate>
@property (nonatomic, strong) IBOutlet UIWebView *webView;
@end

m file:

#import "ViewController.h"
@interface ViewController ()
@property (strong, nonatomic) UIDocumentInteractionController *controller;
@end

@implementation ViewController
@synthesize webView;

//code for pdf file

- (IBAction)openDocument:(id)sender {

NSURL *adobeURL = [[NSBundle mainBundle] URLForResource:@"Interactive_Collateral_Form" withExtension:@"pdf"];
self.controller = [UIDocumentInteractionController interactionControllerWithURL:adobeURL];
self.controller.delegate = self;
self.controller.UTI = @"com.adobe.pdf";

[self.controller presentOpenInMenuFromRect:self.view.bounds inView:self.view animated:YES];
    }

//code for background gif image

- (void)viewDidLoad
{
NSString *pathImg = [[NSBundle mainBundle] pathForResource:@"background" ofType:@"gif"];
NSString* webViewContent = [NSString stringWithFormat:
                            @"<html><body><img style='width:760;height:1024;' src=\"file://%@\"     /></body></html>", pathImg];
[webView loadHTMLString:webViewContent baseURL:nil];

webView.scrollView.bounces = NO;
webView.scrollView.scrollEnabled = NO;
webView.opaque=FALSE;
[webView setBackgroundColor:[UIColor clearColor]];
      }

I am assuming I can add the same code to all the different view controllers. If that is not true, let me know. Im not great at this so any details you can give would be helpful. Thank you in advance!

  • Your question is unclear. Do you have a problem with the code you posted or do you simply want to know how to use this same come in multiple view controllers? – rmaddy Feb 19 '14 at 19:02
  • Sorry for the confusion, When i currently click the button in the view controller, everything slightly dims. When i touch the screen again, it goes back to normal. Nothing happens with the PDF or reader showing up like i need. – user3246366 Feb 19 '14 at 19:05
  • Try presenting the `UIDocumentInteractionController` from the button instead of the entire `self.view`. – rmaddy Feb 19 '14 at 19:07
  • I think the UIDocumentInteractionController may not be what i actually want. I just want the PDF to automatically open in the viewer when my custom-made button is pressed. (thanks for being patient with me) – user3246366 Feb 19 '14 at 19:12
  • Wouldn't it be better to let the user choose the app to view the PDF in? This is what the `UIDocumentInteractionController` will do - let the user choose. – rmaddy Feb 19 '14 at 19:13
  • This particular app will only be used in house for our sales team. The app is a sales tool so I just want them to be able to hit the button, fill out the interactive PDF form, and go back to using the app. I tried using webview, but the interactive parts dont work. Giving these guys too many options will have them skipped the form all together... they aren't that tech savvy! – user3246366 Feb 19 '14 at 19:18

1 Answers1

0

After much research, I figured out what to do. I saved the local PDF in the Adobe Reader app. From there, I added the following url scheme to have my button open the PDF in the Adobe reader without using a UIDocumentInteractionController. Then just link the IBAction to your button.

h file:

- (IBAction)adobeButton;

m file:

- (IBAction)adobeButton {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"com.adobe.Adobe-Reader://Interactive_Collateral_Form.pdf"]];
}