Export Word to ImageSource in WPF

Besides converting a document to a different file format (like PDF, HTML, and image), 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 Graphical User Interface (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="ExportToImageSource.MainWindow"
        Title="Export to ImageSource / Image Control"

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

using GemBox.Document;
using System.Windows;

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

            // If using the 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 GemBox.Document
Imports System.Windows

Namespace ExportToImageSource
    Partial Public Class MainWindow
        Inherits Window

        Public Sub New()


            ' If using the 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

See also

Next steps

GemBox.Document is a .NET component that enables you to read, write, edit, convert, and print document files from your .NET applications using one simple API. How about testing it today?

Download Buy