4   Developing Applications

4.1   Opening PDFs on Android

To launch Reader Mobile directly from your application, use the code below. The file must be accessible to Reader.

File f = new File(filepath);
     Intent i = new Intent();
     i.setAction(Intent.ACTION_VIEW);
     i.setData(Uri.fromFile(f));
     i.setComponent(new ComponentName("com.adobe.reader", "com.adobe.reader.AdobeReader"));
     try
     {
       startActivity(i);
     }
     catch (ActivityNotFoundException e)
     {
       Log.i("App_Tag","Exception - "+e.getMessage());
     }

4.2   Opening PDFs on iOS

To launch Reader Mobile directly from your application, use the code below. The file must be accessible to Reader.

// First, try to open the file with Reader
NSURL *url = [ARClipboardFileTransport.shared transportURLForPath:myDocumentPath scheme:ARClipboardFileTransport.shared.readerScheme pasteboardType:ARClipboardFileTransport.shared.pdfPasteboardType];
  if ([ARClipboardFileTransport.shared docFitsInClipboard:myDocumentPath] && [UIApplication.sharedApplication canOpenURL:url])
{
  // Copy the data to the clipboard
  [UIPasteboard removePasteboardWithName:ARClipboardFileTransport.shared.pdfPasteboardType];
  UIPasteboard *board = [UIPasteboard pasteboardWithName:ARClipboardFileTransport.shared.pdfPasteboardType create:YES];
  NSData *data = [NSData dataWithContentsOfURL:myDocumentPath options:NSDataReadingMappedIfSafe error:nil];
  [board setData:data forPasteboardType:ARClipboardFileTransport.shared.pdfPasteboardType];

  // Switch to Reader
  [UIApplication.sharedApplication openURL:url];
}
else
{
  // If Reader is not installed or the file too big, do a classic Open In...
  // We need to make this a strong property; otherwise, it'll get released immediately
  // after the popover has been shown. We could set up a delegate to release it as soon
  // as we're done with it, but that's really unnecessary complexity since with the simpler
  // code we hold on to no more than one of these at a time.
  [self.docInteractionController dismissMenuAnimated:NO];
  self.docInteractionController = [UIDocumentInteractionController interactionControllerWithURL:myDocumentURL];
  [self.docInteractionController presentOptionsMenuFromBarButtonItem:sender animated:YES];
}