Export PowerPoint to ImageSource in WPF

The WPF Image control allows you to display images in an application. You can use the GemBox.Presentation API to convert a PowerPoint slide to an image.

With the following example, you can see how converting a presentation slide to an ImageSource instance works. You will also see how to attach the converted image to WPF's Image control.

PowerPoint slide exported to ImageSource with GemBox.Presentation
Screenshot of 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

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.Presentation 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.