Created
December 26, 2025 11:30
-
-
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
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 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