Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

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

Select an option

Save conholdate-gists/ae6f74503da10bfdfbe081cbc2dff219 to your computer and use it in GitHub Desktop.
Programmatic .NET Implementation: Convert PPT to PNG Using C# SDK
using System;
using System.IO;
using Aspose.Slides;
using Aspose.Slides.Export;
using System.Drawing.Imaging;
class PptToPngConverter
{
static void Main()
{
// Set up license (replace with your actual license file)
var license = new License();
license.SetLicense("Conholdate.Total.lic");
string inputPath = "sample.pptx";
string outputDir = "output";
// Ensure output directory exists
Directory.CreateDirectory(outputDir);
try
{
using (Presentation pres = new Presentation(inputPath))
{
int slideCount = pres.Slides.Count;
Console.WriteLine($"Found {slideCount} slide(s). Starting conversion...");
for (int i = 0; i < slideCount; i++)
{
// 2x scaling for ~150 DPI; adjust as needed
using (var bitmap = pres.Slides[i].GetThumbnail(2, 2))
{
string outPath = Path.Combine(outputDir, $"slide_{i + 1}.png");
bitmap.Save(outPath, ImageFormat.Png);
Console.WriteLine($"Slide {i + 1} saved to {outPath}");
}
}
}
Console.WriteLine("All slides converted successfully.");
}
catch (Exception ex)
{
Console.Error.WriteLine($"Conversion failed: {ex.Message}");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment