Convert PowerPoint files to image formats
With GemBox.Presentation you can easily convert PowerPoint files to images using just C# or VB.NET code. You can save your presentations to any type of The following example shows how you can convert a PowerPoint slide to a PNG image of a specified size. Saving a single PowerPoint presentation slide as an image is useful for generating the presentation's preview or thumbnail. To create a single PNG or JPEG file from a PowerPoint file, you need to save the presentation with The following example shows how you can convert all PowerPoint slides to a multi-page TIFF image. For this to work you need to select an image format that supports multiple frames, like TIFF or GIF, and specify the You can also save each slide from a PowerPoint presentation as a separate PNG or JPEG image, as shown in the following example.ImageSaveFormat
like PNG, JPEG, SVG, BMP, WMP, GIF, or TIFF.Convert a PowerPoint file to a single image
using GemBox.Presentation;
class Program
{
static void Main()
{
// If using the Professional version, put your serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
// Load a PowerPoint file into the PresentationDocument object.
var presentation = PresentationDocument.Load("%InputFileName%");
// Create image save options.
var imageOptions = new ImageSaveOptions(ImageSaveFormat.Png)
{
SlideNumber = 0, // Select the first slide.
Width = 1240 // Set the image width and keep the aspect ratio.
};
// Save the PresentationDocument object to a PNG file.
presentation.Save("Output.png", imageOptions);
}
}
Imports GemBox.Presentation
Module Program
Sub Main()
' If using the Professional version, put your serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY")
' Load a PowerPoint file into the PresentationDocument object.
Dim presentation = PresentationDocument.Load("%InputFileName%")
' Create image save options.
Dim imageOptions As New ImageSaveOptions(ImageSaveFormat.Png) With
{
.SlideNumber = 0, ' Select the first slide.
.Width = 1240 ' Set the image width and keep the aspect ratio.
}
' Save the PresentationDocument object to a PNG file.
presentation.Save("Output.png", imageOptions)
End Sub
End Module
ImageSaveOptions
.Convert a PowerPoint file to a multi-frame image
using GemBox.Presentation;
class Program
{
static void Main()
{
// If using the Professional version, put your serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
// Load a PowerPoint file.
var presentation = PresentationDocument.Load("%InputFileName%");
// Max integer value indicates that all presentation slides should be saved.
var imageOptions = new ImageSaveOptions(ImageSaveFormat.Tiff)
{
SlideCount = int.MaxValue
};
// Save the TIFF file with multiple frames, each frame represents a single PowerPoint slide.
presentation.Save("Output.tiff", imageOptions);
}
}
Imports GemBox.Presentation
Module Program
Sub Main()
' If using the Professional version, put your serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY")
' Load a PowerPoint file.
Dim presentation = PresentationDocument.Load("%InputFileName%")
' Max integer value indicates that all presentation slides should be saved.
Dim imageOptions As New ImageSaveOptions(ImageSaveFormat.Tiff) With
{
.SlideCount = Integer.MaxValue
}
' Save the TIFF file with multiple frames, each frame represents a single PowerPoint slide.
presentation.Save("Output.tiff", imageOptions)
End Sub
End Module
ImageSaveOptions.SlideCount
property.Convert a PowerPoint file to multiple images
using GemBox.Presentation;
using System.IO;
using System.IO.Compression;
class Program
{
static void Main()
{
// If using the Professional version, put your serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
// Load a PowerPoint file.
var presentation = PresentationDocument.Load("%InputFileName%");
var imageOptions = new ImageSaveOptions();
// Get PowerPoint pages, one for each slide.
var pages = presentation.GetPaginator().Pages;
// Create a ZIP file for storing PNG files.
using (var archiveStream = File.OpenWrite("Output.zip"))
using (var archive = new ZipArchive(archiveStream, ZipArchiveMode.Create))
{
// Iterate through the PowerPoint pages.
for (int pageIndex = 0; pageIndex < pages.Count; pageIndex++)
{
PresentationDocumentPage page = pages[pageIndex];
// Create a ZIP entry for each slide.
var entry = archive.CreateEntry($"Slide {pageIndex + 1}.png");
// Save each slide as a PNG image to the ZIP entry.
using (var imageStream = new MemoryStream())
using (var entryStream = entry.Open())
{
page.Save(imageStream, imageOptions);
imageStream.CopyTo(entryStream);
}
}
}
}
}
Imports GemBox.Presentation
Imports System.IO
Imports System.IO.Compression
Module Program
Sub Main()
' If using the Professional version, put your serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY")
' Load a PowerPoint file.
Dim presentation = PresentationDocument.Load("%InputFileName%")
Dim imageOptions As New ImageSaveOptions()
' Get PowerPoint pages, one for each slide.
Dim pages = presentation.GetPaginator().Pages
' Create a ZIP file for storing PNG files.
Using archiveStream = File.OpenWrite("Output.zip")
Using archive As New ZipArchive(archiveStream, ZipArchiveMode.Create)
' Iterate through the PowerPoint pages.
For pageIndex As Integer = 0 To pages.Count - 1
Dim page As PresentationDocumentPage = pages(pageIndex)
' Create a ZIP entry for each slide.
Dim entry = archive.CreateEntry($"Slide {pageIndex + 1}.png")
' Save each slide as a PNG image to the ZIP entry.
Using imageStream As New MemoryStream()
Using entryStream = entry.Open()
page.Save(imageStream, imageOptions)
imageStream.CopyTo(entryStream)
End Using
End Using
Next
End Using
End Using
End Sub
End Module