Created
January 15, 2026 20:05
-
-
Save conholdate-gists/7e13a18e141b73ee627140e6fefed253 to your computer and use it in GitHub Desktop.
Programmatic .NET Implementation: Convert PPT to PNG Using C# SDK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.IO; | |
| using Aspose.Slides; | |
| using System.Drawing.Imaging; | |
| namespace PptToPngConverter | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| // Paths (adjust as needed) | |
| string inputPath = "sample.pptx"; | |
| string outputDir = "output"; | |
| // Ensure output directory exists | |
| if (!Directory.Exists(outputDir)) | |
| Directory.CreateDirectory(outputDir); | |
| try | |
| { | |
| // Load the presentation | |
| using (Presentation presentation = new Presentation(inputPath)) | |
| { | |
| int slideCount = presentation.Slides.Count; | |
| Console.WriteLine($"Found {slideCount} slide(s). Starting conversion..."); | |
| // Convert each slide to PNG with 300 DPI | |
| for (int i = 0; i < slideCount; i++) | |
| { | |
| ISlide slide = presentation.Slides[i]; | |
| using (var bitmap = slide.GetThumbnail(300, 300)) | |
| { | |
| string outPath = Path.Combine(outputDir, $"slide_{i + 1}.png"); | |
| bitmap.Save(outPath, ImageFormat.Png); | |
| Console.WriteLine($"Saved slide {i + 1} to {outPath}"); | |
| } | |
| } | |
| } | |
| Console.WriteLine("All slides have been converted successfully."); | |
| } | |
| catch (Exception ex) | |
| { | |
| Console.Error.WriteLine($"Error during PPT to PNG conversion: {ex.Message}"); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment