Export PowerPoint to ImageSource in WPF

Following example shows how to convert PowerPoint presentation slide to ImageSource instance and attach it to WPF's Image control.

Screenshot of PowerPoint slide exported to ImageSource with GemBox.Presentation
PowerPoint slide exported to ImageSource with GemBox.Presentation
<Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Export to ImageSource Example" 
        SizeToContent="WidthAndHeight">

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

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

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

        SetImageSource(this.ImageControl);
    }

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

        var presentation = new PresentationDocument();

        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        var textBox = slide.Content.AddTextBox(ShapeGeometryType.Rectangle, 2, 2, 8, 4, LengthUnit.Centimeter);
        textBox.Shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.DarkGray));

        var run = textBox.AddParagraph().AddRun("Hello World!");
        run.Format.Fill.SetSolid(Color.FromName(ColorName.Black));

        image.Source = presentation.ConvertToImageSource(SaveOptions.Image);
    }
}
Imports System.Windows
Imports System.Windows.Controls
Imports GemBox.Presentation

Class MainWindow

    Public Sub New()

        InitializeComponent()

        SetImageSource(Me.ImageControl)
    End Sub

    Private Shared Sub SetImageSource(image As Image)

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

        Dim presentation = New PresentationDocument()

        Dim slide = presentation.Slides.AddNew(SlideLayoutType.Custom)

        Dim textBox = slide.Content.AddTextBox(ShapeGeometryType.Rectangle, 2, 2, 8, 4, LengthUnit.Centimeter)
        textBox.Shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.DarkGray))

        Dim run = textBox.AddParagraph().AddRun("Hello World!")
        run.Format.Fill.SetSolid(Color.FromName(ColorName.Black))

        image.Source = presentation.ConvertToImageSource(SaveOptions.Image)
    End Sub
End Class

Check next example or download examples from GitHub.