Skip to main content

Export Presentation Slides to Images

  • 3 minutes to read

The DevExpress Presentation API exports presentation slides to raster and vector image formats for previews, thumbnails, or downstream processing.

Supported Image Formats

  • BMP
  • EMF
  • GIF
  • ICO
  • JPEG
  • PNG
  • SVG
  • TIFF
  • WMF

Export All Slides to Images

Use the Presentation.exportToImages() method to export all presentation slides. The method returns an array of DXImage objects, where each array element corresponds to a slide in the presentation.

Use the DXImage.save() method to save exported images in any supported format.

The following code snippet exports all slides to PNG files and saves them to the specified directory:

package presentation;

import com.devexpress.docs.presentation.*;
import com.devexpress.drawing.*;
import java.nio.file.*;

// Load a presentation.
try(Presentation presentation = new Presentation(
        Files.readAllBytes(Path.of("presentation.pptx")))) {

    // Export all slides to images.
    DXImage[] images = presentation.exportToImages();

    // Create an output directory.
    Path outputDir = Path.of("output");
    Files.createDirectories(outputDir);

    try {
        // Save each slide as a PNG image.
        for (int i = 0; i < images.length; i++) {
            Path imagePath = outputDir.resolve("slide_" + (i + 1) + ".png");
            images[i].save(imagePath.toString(), DXImageFormat.getPng());
        }
    } finally {
        // Release image resources.
        for (DXImage image : images) {
            if (image != null) {
                image.close();
            }
        }
    }
}

Note

DXImage objects implement native resources and should be closed when no longer needed.

Configure Image Export Options

Pass an ImageExportOptions object to the Presentation.exportToImages(exportOptions) method to customize image export settings.

Rasterize Slides

Use the ImageExportOptions.setRasterize() method to control whether slides are exported as raster or vector images:

  • false (default) — exports slides as vector images (EMF or SVG, depending on the output format).
  • true — exports slides as raster images (DXBitmap).

When rasterization is enabled, the resolution setting specifies image dimensions and DPI metadata.

Specify Resolution

Use the ImageExportOptions.setResolution() method to specify the resolution of exported raster images in DPI. The default value is 96.

The following code snippet exports slides as raster images with a resolution of 300 DPI:

import com.devexpress.docs.presentation.*;
import com.devexpress.drawing.*;

ImageExportOptions options = new ImageExportOptions();
options.setRasterize(true);
options.setResolution(300);

DXImage[] images = presentation.exportToImages(options);

Note

Higher DPI values produce larger images and can improve output quality when printing or displaying images at large sizes.

Export Specific Slides

To export only specific slides, pass an array of zero-based slide indexes to the exportToImages(int[] slideIndexes) method:

The following example exports the first and third slides:

import com.devexpress.docs.presentation.*;
import com.devexpress.drawing.*;

DXImage[] images = presentation.exportToImages(new int[]{0, 2});

Important Notes

  • Slide indexes are zero-based.
  • Use ImageExportOptions to control rasterization and image resolution.
  • Exported images preserve the visual appearance of presentation slides, including text, shapes, pictures, and other supported slide content.
See Also