Skip to content

Instantly share code, notes, and snippets.

@conholdate-gists
Created December 26, 2025 11:30
Show Gist options
  • Select an option

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

Select an option

Save conholdate-gists/4bd6de09519a139bed5eaae640af1476 to your computer and use it in GitHub Desktop.
Convert PPTX to PNG and JPG in C# with Conholdate.total – .NET Implementation
using System;
using System.IO;
using Conholdate.Total; // Ensure the SDK namespace is referenced
class Program
{
static void Main()
{
// Path to the source PPTX file
string sourcePath = "input.pptx";
// Load the presentation
using var presentation = new Presentation(sourcePath);
// Iterate through each slide
for (int i = 0; i < presentation.Slides.Count; i++)
{
// Define output file names
string pngFile = Path.Combine("output", $"slide_{i + 1}.png");
string jpgFile = Path.Combine("output", $"slide_{i + 1}.jpg");
// Ensure output directory exists
Directory.CreateDirectory("output");
// Save slide as PNG
using (var pngStream = new FileStream(pngFile, FileMode.Create))
{
presentation.Save(pngStream, SaveFormat.Png,
new ImageSaveOptions { SlideIndex = i });
}
// Save slide as JPG with high quality
using (var jpgStream = new FileStream(jpgFile, FileMode.Create))
{
var jpgOptions = new ImageSaveOptions
{
SlideIndex = i,
JpegQuality = 90 // Increase quality to reduce compression artifacts
};
presentation.Save(jpgStream, SaveFormat.Jpeg, jpgOptions);
}
Console.WriteLine($"Slide {i + 1} saved as PNG and JPG.");
}
Console.WriteLine("Conversion completed successfully.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment