Export PDF file to ImageSource in WPF

The WPF Image control allows you to display images in an application. You can use GemBox.Pdf to convert a PDF page to an image.

The following example shows how to convert a PDF page to an ImageSource instance and attach it to WPF's Image control.

PDF page exported to ImageSource with GemBox.Pdf
Screenshot of PDF page exported to ImageSource with GemBox.Pdf
<Window x:Class="MainWindow"
        Title="Export to ImageSource Example" 

        <Menu DockPanel.Dock="Top">
            <MenuItem Header="_File">
                <MenuItem Header="_Open" Click="MenuItem_Click" />
        <Border Margin="10" BorderBrush="Black" BorderThickness="1">
            <Image x:Name="ImageControl"/>

using GemBox.Pdf;
using Microsoft.Win32;
using System.Windows;

public partial class MainWindow : Window
    public MainWindow()


    private void MenuItem_Click(object sender, RoutedEventArgs e)
        OpenFileDialog fileDialog = new OpenFileDialog();
        fileDialog.Filter = "PDF files (*.pdf)|*.pdf";

        if (fileDialog.ShowDialog() == true)
            using (var document = PdfDocument.Load(fileDialog.FileName))
                this.ImageControl.Source = document.ConvertToImageSource(SaveOptions.Image);
Imports GemBox.Pdf
Imports Microsoft.Win32

Class MainWindow

    Public Sub New()


    End Sub

    Private Sub MenuItem_Click(sender As Object, e As RoutedEventArgs)

        Dim fileDialog = New OpenFileDialog()
        fileDialog.Filter = "PDF files (*.pdf)|*.pdf"

        If (fileDialog.ShowDialog() = True) Then
            Using document = PdfDocument.Load(fileDialog.FileName)
                Me.ImageControl.Source = document.ConvertToImageSource(SaveOptions.Image)
            End Using
        End If

    End Sub
End Class

See also

Next steps

GemBox.Pdf is a .NET component that enables developers to read, merge and split PDF files or execute low-level object manipulations from .NET applications in a simple and efficient way.

Download Buy