Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save conholdate-gists/b99c41e059122cdea4d67fba80884437 to your computer and use it in GitHub Desktop.

Select an option

Save conholdate-gists/b99c41e059122cdea4d67fba80884437 to your computer and use it in GitHub Desktop.
Convert PPTX to PNG with Conholdate.Total for .NET
using System;
using System.IO;
using Conholdate.Total.Slides;
class Program
{
static void Main()
{
// Path to the source PPTX file
string inputPath = "sample.pptx";
// Folder where PNG files will be saved
string outputDir = "output";
Directory.CreateDirectory(outputDir);
// Load the presentation
using (Presentation presentation = new Presentation(inputPath))
{
// Configure PNG output options
var options = new ImageSaveOptions(SaveFormat.Png)
{
DpiX = 300, // Horizontal DPI
DpiY = 300, // Vertical DPI
CompressionLevel = 9 // Maximum compression
};
// Iterate through each slide and save as PNG
for (int i = 0; i < presentation.Slides.Count; i++)
{
string outPath = Path.Combine(outputDir, $"slide_{i + 1}.png");
presentation.Slides[i].Save(outPath, options);
Console.WriteLine($"Saved {outPath}");
}
}
Console.WriteLine("Conversion completed.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment