# Using SkiaImageFormatProvider

| Minimum Version  | R3 2022                                |
| ---------------- | -------------------------------------- |
| Target Framework | .NET Standard / .NET (Target OS: None) |

Use `SkiaImageFormatProvider` to export `RadFixedPage` objects to `.png`, `.jpg`, `.jpeg`, or `.webp` images through the third-party [SkiaSharp](https://learn.microsoft.com/en-us/previous-versions/xamarin/xamarin-forms/user-interface/graphics/skiasharp/) library. To export a full PDF document, iterate its pages and save each page as a separate image.

> important This feature is available for cross-platform `.NET Standard` and `.NET` targets that use `Target OS: None`. For WPF and WinForms-specific alternatives, refer to these articles:
>
> * [ThumbnailFactory](https://docs.telerik.com/devtools/wpf/controls/radpdfviewer/export-fixedpage-to-image)
> * [How to Export Each Page as an Image in PDF Documents](https://docs.telerik.com/devtools/winforms/knowledge-base/pdfviewer-export-page-images-with-no-ui)

## Requirements

To enable the image export functionality in your application, add references to the following packages:

* The `Telerik.Documents.Fixed.FormatProviders.Image.Skia` NuGet package.
* The `SkiaSharp` NuGet package.
* The `SkiaSharp.NativeAssets.*` NuGet package. This package may differ depending on the target platform. Versions are available for Windows, macOS, Linux, WebAssembly, Android, iOS, and others.

Set up a [FontsProvider implementation](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/cross-platform/fonts#setting-and-exporting-fonts) so the renderer can read document fonts and draw the image correctly.

## Exporting Pages to Images

To convert document pages to images, use the `Export()` method. `SkiaImageFormatProvider` exports `RadFixedPage` objects, not `RadFixedDocument` objects. Iterate the pages of a PDF document and save each page in a separate file.

**Export RadFixedDocument to Image**

```C#
PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
RadFixedDocument fixedDocument = pdfFormatProvider.Import(File.ReadAllBytes("Sample.pdf"), TimeSpan.FromSeconds(10));
SkiaImageFormatProvider imageProvider = new SkiaImageFormatProvider();

int count = 1;
foreach (RadFixedPage page in fixedDocument.Pages)
{
    byte[] resultImage = imageProvider.Export(page, TimeSpan.FromSeconds(10));

    File.WriteAllBytes(@"C:\Temp\Page " + count++ + ".png", resultImage);
}
```

## Exporting Asynchronously

Use `ExportAsync()` when you want to perform the conversion asynchronously.

**Export RadFixedDocument to Image Async**

```C#
public async void ExportAsync()
{
    PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
    RadFixedDocument fixedDocument = pdfFormatProvider.Import(File.ReadAllBytes("Sample.pdf"), TimeSpan.FromSeconds(10));
    SkiaImageFormatProvider imageProvider = new SkiaImageFormatProvider();

    int count = 0;

    await Parallel.ForEachAsync(fixedDocument.Pages, async (page, token) =>
    {
        int currentCount = Interlocked.Increment(ref count);

        byte[]? result = await imageProvider.ExportAsync(page, TimeSpan.FromSeconds(10));

        File.WriteAllBytes(@"C:\my_temp\Page" + currentCount + ".png", result);

    });
}
```

## Export Settings

The `SkiaImageFormatProvider` exposes [SkiaImageExportSettings](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/formats-and-conversion/convert-to-image/settings) so you can control the image format, quality, scaling, and antialiasing.

## See Also

* [Converting XLSX Content to DOCX Document](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/convert-excel-content-to-word-document)
* [Export Worksheet to image](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/spreadprocessing-export-worksheet-to-image-netstandard)
* [Cropping PDF Pages and Saving as Images Using RadPdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/crop-save-pdf-pages-as-images-radpdfprocessing)
* [Converting a PDF Document to a Multipage TIFF Image](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/convert-pdf-to-multipage-tiff-radpdfprocessing)
* [Converting Multi-page TIFF Images to PDF](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/convert-tiff-to-pdf-radpdfprocessing)
* [Timeout Mechanism](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/timeout-mechanism-in-dpl)
* [SkiaImageExportSettings](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/formats-and-conversion/convert-to-image/settings)
