Export Word to ImageSource in WPF

Following example shows how to convert document page to ImageSource instance and attach it to WPF's Image control.

Export to ImageSource / Image Control Screenshot
<Window x:Class="ConvertToImageSourceCs.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Export to ImageSource Sample" 
        SizeToContent="WidthAndHeight">

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

</Window>
using System.Windows;
using System.Windows.Controls;
using GemBox.Document;

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();

        SetImageSource(this.ImageControl);
    }

    private static void SetImageSource(Image image)
    {
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        DocumentModel document = new DocumentModel();

        var section = new GemBox.Document.Section(document);
        document.Sections.Add(section);

        var paragraph = new GemBox.Document.Paragraph(document);
        section.Blocks.Add(paragraph);

        var run = new GemBox.Document.Run(document, "Hello World!");
        paragraph.Inlines.Add(run);

        image.Source = document.ConvertToImageSource(SaveOptions.ImageDefault);
    }
}
Imports System.Windows
Imports System.Windows.Controls
Imports GemBox.Document

Partial Public Class MainWindow
    Inherits Window

    Public Sub New()
        InitializeComponent()

        SetDocumentViewer(Me.ImageControl)
    End Sub

    Private Shared Sub SetDocumentViewer(image As Image)

        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Dim document = New DocumentModel()

        Dim section = New GemBox.Document.Section(document)
        document.Sections.Add(section)

        Dim paragraph = New GemBox.Document.Paragraph(document)
        section.Blocks.Add(paragraph)

        Dim run = New GemBox.Document.Run(document, "Hello World!")
        paragraph.Inlines.Add(run)

        image.Source = document.ConvertToImageSource(SaveOptions.ImageDefault)

    End Sub

End Class

Check next example or download examples from GitHub.