Export Presentation Slides to Images with DevExpress Presentation API Library
- 3 minutes to read
Export Entire Presentation to Images
Call the Presentation.ExportToImages method to export presentation slides to images. This method returns an array of DXImage objects. Each array element in an exported slide.
The following code snippet exports all slides from a presentation as PNG images and saves them to a specified directory:
using DevExpress.Docs.Presentation;
using DevExpress.Drawing;
namespace PresentationApiSample;
public class Program {
public static async Task Main(string[] _) {
// Load the presentation from a file
Presentation presentation = new Presentation(File.ReadAllBytes(@"D:\presentation_to_export.pptx"));
// Export all slides to images
DXImage[] images = presentation.ExportToImages();
// Create an output directory
string outputDir = @"D:\presentation_as_images";
Directory.CreateDirectory(outputDir);
// Save each image to a file
for (int i = 0; i < images.Length; i++) {
images[i].Save(Path.Combine(outputDir, $"{i}.png"), DXImageFormat.Png);
}
}
}
You can call the DXImage.Save method to save DXImage objects in different formats. The DXImageFormat class contains all supported image formats:
- BMP
- EMF
- GIF
- Icon
- JPEG
- PNG
- SVG
- TIFF
- WMF
Image Export Options
Pass ImageExportOptions to the Presentation.ExportToImages method to specify image export settings. You can specify the following options:
- Rasterize
- If set to
false(default), slides are exported as vector images (EMF/SVG). If set totrue, slides are exported as raster images (DXBitmap). If an image is rasterized, theResolutionoption specifies the image size and the resolution value written to the image metadata. - Resolution
- Specifies the resolution of exported raster images, in DPI. The default value is 96 DPI.
using DevExpress.Docs.Presentation;
using DevExpress.Drawing;
DXImage[] images = presentation.ExportToImages(new ImageExportOptions { Rasterize = true, Resolution = 300 });
Export Specific Slides to Images
Pass an array of zero-based slide indexes to the Presentation.ExportToImages method to export specific slides from a presentation:
using DevExpress.Docs.Presentation;
using DevExpress.Drawing;
DXImage[] images = presentation.ExportToImages([0, 2]);
See Also