I need to open a local PDF using Adobe Reader app via an IBaction using a Button

喜夏-厌秋 提交于 2019-12-25 12:26:14

问题


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!


回答1:


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"]];
}


来源:https://stackoverflow.com/questions/21889831/i-need-to-open-a-local-pdf-using-adobe-reader-app-via-an-ibaction-using-a-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!