Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

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

Select an option

Save conholdate-gists/426ef8aab90217a6e21c90f11dd23f3c to your computer and use it in GitHub Desktop.
Convert PPTX to Markdown with Conholdate.Total for .NET
using System;
using System.IO;
using Conholdate.Total;
using Conholdate.Total.Presentation;
using Conholdate.Total.Presentation.Export;
class Program
{
static void Main(string[] args)
{
// Validate arguments
if (args.Length != 2)
{
Console.WriteLine("Usage: PptxToMarkdown <input.pptx> <output.md>");
return;
}
string inputPath = args[0];
string outputPath = args[1];
try
{
// Load the PPTX file
using (Presentation presentation = new Presentation(inputPath))
{
// Configure markdown export options
var mdOptions = new MarkdownExportOptions
{
PreserveSlideTitles = true,
ImageExportFormat = ImageExportFormat.Png,
IncludeNotes = true,
EmbedImages = false // set true to embed as base64
};
// Perform conversion
string markdown = presentation.Save(mdOptions);
// Write markdown to file
File.WriteAllText(outputPath, markdown);
Console.WriteLine($"Conversion successful. Markdown saved to {outputPath}");
}
}
catch (PresentationException ex)
{
Console.Error.WriteLine($"Conversion failed: {ex.Message}");
}
catch (Exception ex)
{
Console.Error.WriteLine($"Unexpected error: {ex.Message}");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment