Quicklook/QLPreviewController shows a blank page instead of pdf on ios 8 RRS feed

  • Question

  • User107114 posted

    Hello All, I am new to iOS development and trying to develop app with xamarin and quicklook/QLPreviewController for pdf preview but it is showing blank page with pdf name in title and below that text like "portable document format"

    Here is the code i am referring from


    I have attached my screen shot also.

    Please help me, Thanks in advance

    Thanks, Avinash

    Wednesday, February 18, 2015 1:10 PM

All replies

  • User19283 posted

    Hi Avinash,

    I have implemented this open PDF function, with help of Sasha's blog...

    I had the same problem because I've passed a "new NSUrl(myurl)" in place of 'NSUrl.FromFileName(myurl).

    Here my code that is working :

    first, create your customs classes, overriding QLPreview classes

    ``` public class PreviewItem : QLPreviewItem { public string Title { get; set; } public NSUrl Url { get; set; } public override string ItemTitle { get {return Title;} } public override NSUrl ItemUrl { get { return Url; } } }

    public class PreviewDatasource : QLPreviewControllerDataSource
        private NSUrl _url;
        private string _title;
        public PreviewDatasource(NSUrl url, string Title)
            _url = url;
            _title = Title;
        public override nint PreviewItemCount(QLPreviewController controler)
            return 1;
        public override IQLPreviewItem GetPreviewItem(QLPreviewController controler, nint index)
            return new PreviewItem { Title = _title, Url = _url };


    next, call to display the PDF file (in my case, after downloading PDF file in local... code provided) :

        BTProgressHUD.ShowContinuousProgress ("Téléchargement en cours...", ProgressHUD.MaskType.Clear);
        Uri uri = new Uri (url);
        string documentpath = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
        string localfilename = Path.GetFileName (uri.AbsoluteUri);
        string localpath = Path.Combine (documentpath, localfilename);
        var webclient = new WebClient ();
        webclient.DownloadFileCompleted+= (sender, e) => {
            if (e.Error == null)
                UIApplication.SharedApplication.InvokeOnMainThread (() => {
                    BTProgressHUD.ShowSuccessWithStatus("Téléchargement terminé", 1500);
                    QLPreviewController qlpreview = new QLPreviewController();
                    qlpreview.DataSource = new PreviewDatasource(NSUrl.FromFilename(localpath), localfilename);  
                    PresentViewController(qlpreview, true, null);
            } else {
                UIApplication.SharedApplication.InvokeOnMainThread (() => {
                BTProgressHUD.ShowErrorWithStatus("Téléchargement échoué", 1500);
        webclient.DownloadFileAsync (uri, localpath);

    Hope this helps...

    Wednesday, May 13, 2015 9:12 AM
  • User119192 posted

    Hi Can we have PDF Form Fields as is the Downloaded PDF File ?, I mean Edit the PDF Form Fields

    Tuesday, January 31, 2017 10:34 PM