After researching this issue, asking the same question on another forum, and using different code examples, I am unable to get this code working using a UIDocumentInteractionController in C#. I can, however, get it working using the objective-c tutorial linked in the above question. This is not useful since I need the code in C# instead of objective-c.
During my research I found this post on Stack Overflow which instead used a QLPreviewController.
Monotouch - Issue with QLPreviewController
This code provides exactly what I need for my application. I made one change to the original location of the PDF and it works as expected.
Here is the code, taken and modified from the above post, I am using to open a PDF in a Quick Preview control which has the "Open In" functionality.
Here is the code for the controller:
QLPreviewController previewController= new QLPreviewController();
previewController.DataSource=new MyQLPreviewControllerDataSource();
this.PresentViewController(previewController,true, null);
Here is the code for the Data Source:
public class MyQLPreviewControllerDataSource : QLPreviewControllerDataSource {
public override int PreviewItemCount (QLPreviewController controller) {
return 1;
}
public override QLPreviewItem GetPreviewItem (QLPreviewController controller, int index)
{
string fileName = @"example.pdf";
var documents = NSBundle.MainBundle.BundlePath;
var library = Path.Combine (documents,fileName);
NSUrl url = NSUrl.FromFilename (library);
return new QlItem ("Title", url);
}
}
Here is the code for the QlItem:
public class QlItem : QLPreviewItem
{
string title;
NSUrl uri;
public QlItem(string title, NSUrl uri)
{
this.title = title;
this.uri = uri;
}
public override string ItemTitle {
get { return title; }
}
public override NSUrl ItemUrl {
get { return uri; }
}
}