iOS print like page selection with preview like in system

IlliaGryshkevychIlliaGryshkevych USMember ✭✭
edited July 2018 in Xamarin.iOS


I am trying to find out how can I show the page selection like iOS has inside for printing.

I have seen several applications which use such thumbnails approach for selection individual pages

Since, iOS has build in document previewer (QLPreviewController), I am curious, whether iOS has something similar which will help me displaying thumbnails of each page.

Thanks for your help


  • LandLuLandLu Member, Xamarin Team Xamurai

    You can try to use UIGraphics to create image for your pdf file's each page, then list them in a control maybe like UICollectionView. Here is my code for creating image list:

    List<UIImage> imagesFromPDFWithDocument(CGPDFDocument document) 
        var imgList = new List<UIImage>();
        for (int i=1; i<=document.Pages; i++)
            CGPDFPage page = document.GetPage(i);
            CGRect pageRect = page.GetBoxRect(CGPDFBox.Crop);
            CGContext context = UIGraphics.GetCurrentContext();
            context.TranslateCTM(pageRect.GetMinX(), pageRect.GetMaxY());
            context.ScaleCTM(1, -1);
            context.TranslateCTM(-pageRect.X, -pageRect.Y);
            UIImage finalImage = UIGraphics.GetImageFromCurrentImageContext();
        return imgList;

    After getting these images, I show them up in a collection view control:

    var filePath = NSBundle.MainBundle.PathForResource("pdfFile", "pdf");
    CGPDFDocument document = new CGPDFDocument(new CGDataProvider(new NSUrl(filePath, false)));
    var images = imagesFromPDFWithDocument(document);
    MyCollectionView.DataSource = new MyCollectionViewDataSource(images);
  • IlliaGryshkevychIlliaGryshkevych USMember ✭✭

    @LandLu said:
    You can try to use UIGraphics to create image for your pdf file's each page

    Thanks man, I will give it a try

Sign In or Register to comment.