Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

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

Select an option

Save conholdate-gists/da726002f222de7980e00634b6ae13c1 to your computer and use it in GitHub Desktop.
Convert PPTX to Markdown with Conholdate.Total for .NET
using System;
using Conholdate.Total.Document;
namespace PptxToMarkdownDemo
{
class Program
{
static void Main(string[] args)
{
// Validate arguments
if (args.Length != 2)
{
Console.WriteLine("Usage: PptxToMarkdownDemo <input.pptx> <output.md>");
return;
}
string inputPath = args[0];
string outputPath = args[1];
try
{
// Initialize the DocumentEngine
var engine = new DocumentEngine();
// Load the PPTX presentation
var presentation = engine.Load(inputPath);
if (presentation == null)
{
Console.WriteLine("Failed to load the PPTX file.");
return;
}
// Configure Markdown save options
var mdOptions = new MarkdownSaveOptions
{
HeadingLevel = 2, // Use level 2 headings for slide titles
EmbedImages = true, // Embed images as base64
ListStyle = MarkdownListStyle.Ordered,
Encoding = System.Text.Encoding.UTF8
};
// Save as Markdown
presentation.Save(outputPath, mdOptions);
Console.WriteLine($"Conversion successful. Markdown saved to: {outputPath}");
}
catch (Exception ex)
{
Console.WriteLine($"Error during conversion: {ex.Message}");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment