Search code examples
pdfxamarin.iosquicklook

Monotouch Example for QuickLook PDF


I am looking for a bare-bones pdf viewer example using the QuickLook Monotouch API. I have searched and have found bits and pieces but just can't seem to get it all integrated.

I will be reading the pdf from a file pre-saved to the Personal folder on the iPad and would like to show the pdf as a modal view.

If someone could post a bare-bones example, that would be much appreciated.

What I have so far is below.

Thanks!

        path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
        pdfPath = System.IO.Path.Combine(path, "pdfReport.pdf");

        QLPreviewController myPdfController = new QLPreviewController();
        MyPdf pdfToShow = new MyPdf("", new Uri(""));   // Not sure about this line
        myPdfController.DataSource = pdfPath;           // Not sure what this line should be
        PresentModalViewController(myPdfController, true);

Solution

  • I just used a UIWebView and loaded it like this:

    NSUrl docUrl = NSUrl.FromFilename(PDFInvoice.FullFilename);
    NSUrlRequest request = new NSUrlRequest(docUrl);
    
    webView.LoadRequest(request);