Quick start guide

Quick start guide

This guide shows you how to convert documents to Markdown with GroupDocs.Markdown for .NET. You’ll have working code in under 2 minutes.

How it works

flowchart LR
    A["Input Document\n(DOCX, PDF, XLSX, EPUB, ...)"]
    B["MarkdownConverter"]
    C["Markdown Output\n(.md file or string)"]
    A --> B --> C

Prerequisites

  1. Install the NuGet package:
dotnet add package GroupDocs.Markdown
Install-Package GroupDocs.Markdown
  1. Add the namespace:
using GroupDocs.Markdown;

Example 1: Convert Word to Markdown

The simplest conversion — one line of code:

using GroupDocs.Markdown;

// Convert a Word document to Markdown
string markdown = MarkdownConverter.ToMarkdown("business-plan.docx");
Console.WriteLine(markdown);

// Or save directly to a file
MarkdownConverter.ToFile("business-plan.docx", "business-plan.md");

business-plan.docx is a sample file used in this example. Click here to download it.

Example 2: Convert PDF with image export

Save a PDF to Markdown with images extracted to a folder:

using GroupDocs.Markdown;

var options = new ConvertOptions
{
    ImageExportStrategy = new ExportImagesToFileSystemStrategy("output/images")
    {
        ImagesRelativePath = "images"
    }
};

MarkdownConverter.ToFile("report.pdf", "output/report.md", options);
// Images saved to output/images/
// Markdown references: ![](images/img-001.png)

report.pdf is a sample file used in this example. Click here to download it.

Example 3: Convert Excel with options

Convert a spreadsheet with column truncation and front matter:

using GroupDocs.Markdown;

var options = new ConvertOptions
{
    MaxColumns = 8,
    MaxRows = 50,
    IncludeFrontMatter = true,
    Flavor = MarkdownFlavor.GitHub
};

using var converter = new MarkdownConverter("budget.xlsx");

// Inspect before converting
DocumentInfo info = converter.GetDocumentInfo();
Console.WriteLine($"Worksheets: {info.PageCount}");

// Convert
ConvertResult result = converter.Convert(options);
Console.WriteLine(result.Content);

// Check warnings
foreach (string w in result.Warnings)
    Console.WriteLine($"Warning: {w}");

budget.xlsx is a sample file used in this example. Click here to download it.

What’s next?