Table of Contents

Method DocxToMarkdown

Namespace
LMKit.Document.Conversion
Assembly
LM-Kit.NET.dll

DocxToMarkdown(byte[], DocxToMarkdownOptions, CancellationToken)

Converts a DOCX document in memory to Markdown text.

public static string DocxToMarkdown(byte[] docxData, DocxToMarkdownOptions options = null, CancellationToken cancellation = default)

Parameters

docxData byte[]

The DOCX binary content.

options DocxToMarkdownOptions

Options controlling DOCX to Markdown conversion behavior.

cancellation CancellationToken

A cancellation token used to cancel the conversion operation.

Returns

string

The converted Markdown content.

Examples

using LMKit.Document.Conversion;

byte[] docxData = File.ReadAllBytes("report.docx");
string markdown = MarkdownDocxConverter.DocxToMarkdown(docxData, new DocxToMarkdownOptions
{
    IncludeTables = true,
    IncludeImages = false
});

File.WriteAllText("report.md", markdown);

DocxToMarkdown(string, DocxToMarkdownOptions, CancellationToken)

Converts a DOCX file to Markdown text.

public static string DocxToMarkdown(string inputPath, DocxToMarkdownOptions options = null, CancellationToken cancellation = default)

Parameters

inputPath string

The DOCX file path to convert.

options DocxToMarkdownOptions

Options controlling DOCX to Markdown conversion behavior.

cancellation CancellationToken

A cancellation token used to cancel the conversion operation.

Returns

string

The converted Markdown content.

Examples

using LMKit.Document.Conversion;

string markdown = MarkdownDocxConverter.DocxToMarkdown("input/spec.docx", new DocxToMarkdownOptions
{
    PreserveLineBreaks = true
});

Console.WriteLine(markdown);

DocxToMarkdown(byte[], bool, bool, bool, bool, bool, CancellationToken)

Converts DOCX bytes to Markdown using individual boolean conversion flags.

public static string DocxToMarkdown(byte[] docxData, bool includeTables = true, bool includeImages = true, bool includeHyperlinks = true, bool includeEmptyParagraphs = false, bool preserveLineBreaks = true, CancellationToken cancellation = default)

Parameters

docxData byte[]
includeTables bool
includeImages bool
includeHyperlinks bool
includeEmptyParagraphs bool
preserveLineBreaks bool
cancellation CancellationToken

Returns

string

Examples

using LMKit.Document.Conversion;

byte[] docxData = File.ReadAllBytes("input.docx");
string markdown = MarkdownDocxConverter.DocxToMarkdown(
    docxData,
    includeTables: true,
    includeImages: false,
    includeHyperlinks: true,
    includeEmptyParagraphs: false,
    preserveLineBreaks: true);

DocxToMarkdown(string, bool, bool, bool, bool, bool, CancellationToken)

Converts a DOCX file to Markdown using individual boolean conversion flags.

public static string DocxToMarkdown(string inputPath, bool includeTables = true, bool includeImages = true, bool includeHyperlinks = true, bool includeEmptyParagraphs = false, bool preserveLineBreaks = true, CancellationToken cancellation = default)

Parameters

inputPath string
includeTables bool
includeImages bool
includeHyperlinks bool
includeEmptyParagraphs bool
preserveLineBreaks bool
cancellation CancellationToken

Returns

string

Examples

using LMKit.Document.Conversion;

string markdown = MarkdownDocxConverter.DocxToMarkdown(
    "input.docx",
    includeTables: true,
    includeImages: true,
    includeHyperlinks: false,
    includeEmptyParagraphs: false,
    preserveLineBreaks: true);

File.WriteAllText("input.md", markdown);