Export Word to ImageSource in WPF

Besides converting a document to a different file format, GemBox.Document also supports converting a document's pages to ImageSource objects with the DocumentModel.ConvertToImageSource method.

If you require more than displaying a file's content, for instance if you want to be able to modify it with some GUI control, take a look at this Word Editor in WPF example.

The following example shows how you can convert a page from a Word file to an image and attach it to WPF's Image control.

Converted page from Word file to ImageSource and attached to WPF's Image control
Screenshot of Word file exported to WPF's Image control
<Window x:Class="ConvertToImageSource.MainWindow"
        Title="Export to ImageSource / Image Control"

    <Border Margin="10" BorderBrush="Black" BorderThickness="1">
        <Image x:Name="ImageControl"/>

using System.Windows;
using GemBox.Document;

namespace ConvertToImageSource
    public partial class MainWindow : Window
        public MainWindow()

            // If using Professional version, put your serial key below.
            this.SetImageControl("%#Reading.docx%", 0);

        private void SetImageControl(string path, int pageIndex)
            var document = DocumentModel.Load(path);

            var imageOptions = new ImageSaveOptions();
            imageOptions.PageNumber = pageIndex;

            var imageSource = document.ConvertToImageSource(imageOptions);
            this.ImageControl.Source = imageSource;
Imports System.Windows
Imports GemBox.Document

Namespace ConvertToImageSource
    Partial Public Class MainWindow
        Inherits Window

        Public Sub New()


            ' If using Professional version, put your serial key below.

            Me.SetImageControl("%#Reading.docx%", 0)

        End Sub

        Private Sub SetImageControl(path As String, pageIndex As Integer)

            Dim document = DocumentModel.Load(path)

            Dim imageOptions As New ImageSaveOptions()
            imageOptions.PageNumber = pageIndex

            Dim imageSource = document.ConvertToImageSource(imageOptions)
            Me.ImageControl.Source = imageSource

        End Sub

    End Class
End Namespace

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.

Like it?

Download Buy

If you want to try the GemBox.Document yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.