For the complete documentation index, see llms.txt. This page is also available as Markdown.

Generate a PDF page thumbnail

You can generate images of pages in documents.

Generate PDF page thumbnails in Xamarin.Android

This tutorial only applies to Xamarin.Android.

Apryse's library provides a page thumbnail dialog which shows thumbnails of all PDF document pages. Fore more information, see thumbnail browser .

With PDFViewCtrl, you can get a thumbnail Bitmap image for each page in a PDF document.

The following example request thumbnail for page 3:

pdfViewCtrl.ThumbAsync += (sender, e) =>
{
    var bitmap = Bitmap.CreateBitmap(e.Width, e.Height, Bitmap.Config.Argb8888);
    bitmap.SetPixels(e.Buf, 0, e.Width, 0, 0, e.Width, e.Height);
    // use the bitmap
};

// request thumbnail for page 3
pdfViewCtrl.GetThumbAsync(3);

where pdfViewCtrl is an instance of PDFViewCtrl.

It is recommended you cancel all thumbnail requests once they are no longer needed. To cancel all thumbnail request, use PDFViewCtrl.cancelAllThumbRequests().

Generate PDF page thumbnails in Xamarin.iOS

To create a PDF page thumbnail in multiple image formats.

PDFDoc doc = new PDFDoc(filename);
PDFDraw draw = new PDFDraw();

// set the output resolution
draw.SetDPI(92);

// Rasterize the first page in the document and save the result as PNG.
Page pg = doc.GetPage(1);
draw.Export(pg, output_filename, "PNG");

Convert PDF to image (JPG, PNG, BMP, TIFF) Full code sample illustrates how to use the built-in rasterizer in order to render PDF images on the fly and how to save resulting images in PNG and JPEG format.

More image format options:

  • "RAW" : RAW format.There are four possibilities:

    • e_rgba - if transparent and color page;

    • e_gray_alpha - if transparent and gray page;

    • e_rgb - if opaque and color page;

    • e_gray - if opaque and gray page. NOTE that if page is set to be transparent (SetPageTransparent), the output color channels are already multiplied by the alpha channel.

  • "BMP" : Bitmap image format (BMP)

  • "JPEG" : Joint Photographic Experts Group (JPEG) image format

  • "PNG" : 24-bit W3C Portable Network Graphics (PNG) image format

  • "PNG8" : 8-bit, palettized PNG format. The exported file size should be smaller than the one generated using "PNG", possibly at the expense of some image quality.

  • "TIFF" : Tag Image File Format (TIFF) image format.

  • "TIFF8" : Tag Image File Format (TIFF) image format (with 8-bit palete).

Last updated

Was this helpful?