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
docxDatabyte[]The DOCX binary content.
optionsDocxToMarkdownOptionsOptions controlling DOCX to Markdown conversion behavior.
cancellationCancellationTokenA 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
inputPathstringThe DOCX file path to convert.
optionsDocxToMarkdownOptionsOptions controlling DOCX to Markdown conversion behavior.
cancellationCancellationTokenA 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
docxDatabyte[]includeTablesboolincludeImagesboolincludeHyperlinksboolincludeEmptyParagraphsboolpreserveLineBreaksboolcancellationCancellationToken
Returns
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
inputPathstringincludeTablesboolincludeImagesboolincludeHyperlinksboolincludeEmptyParagraphsboolpreserveLineBreaksboolcancellationCancellationToken
Returns
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);