Open pdf with other apps

3 Solutions Collect From Internet About “Open pdf with other apps”

This code will present the OpenIn interaction you’re looking for. It works for iPhone and iPad. On iPad its in a popover. I’m generating the PDF but if you’re just using one you have you don’t need to writeToFile, just hand in the filePath.

// In your header. MyViewController.h
@interface MyViewController : UIViewController <UIDocumentInteractionControllerDelegate>
    UIDocumentInteractionController *docController;

// In your implementation. MyViewController.m Open Results is hooked up to a button.
- (void)openResults
    // Generate PDF Data.
    NSData *pdfData = [self makePDF];

    // Create a filePath for the pdf.
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"Report.pdf"];

    // Save the PDF. UIDocumentInteractionController has to use a physical PDF, not just the data.
    [pdfData writeToFile:filePath atomically:YES];

    // Open the controller.
    docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];
    docController.delegate = self;
    docController.UTI = @"com.adobe.pdf";
    [docController presentOpenInMenuFromBarButtonItem:shareButton animated:YES];

To open a file in an available application on the device, use the UIDocumentInteractionController class.

A document interaction controller, along with a delegate object, provides in-app support for managing user interactions with files in the local system. For example, an email program might use this class to allow the user to preview attachments and open them in other apps. Use this class to present an appropriate user interface for previewing, opening, copying, or printing a specified file.

There are a lot of questions around it on SO if you get stuck. search results for UIDocumentInteractionController

You can check with Apple Default api of “UIDocumentInteractionController”.

Below is url:

Hope, it will resolve your issue.