Table of Contents

Interface IDocxToMarkdownConverter

Namespace
DocToolkit.Extensions.DependencyInjection
Assembly
DocToolkit.Extensions.DependencyInjection.dll

Converts a Word (.docx) package to Markdown, keeping the structure ExtractText(byte[]) throws away. Registered by AddDocToolkit(IServiceCollection, Action<DocToolkitOptions>?).

A heading becomes # and a table becomes a pipe table; images come back as data: URIs.

public interface IDocxToMarkdownConverter

Methods

Convert(byte[])

Converts the .docx in docx.

string Convert(byte[] docx)

Parameters

docx byte[]

Returns

string

Exceptions

ArgumentNullException

docx is null.

ArgumentException

docx is empty.

DocumentConversionException

It could not be converted.

ConvertAsync(Stream, CancellationToken)

Reads a .docx from source and returns the converted text. source is read to its end and is not disposed, closed or sought, so it may be forward-only.

Task<string> ConvertAsync(Stream source, CancellationToken ct = default)

Parameters

source Stream
ct CancellationToken

Returns

Task<string>

Exceptions

ArgumentNullException

source is null.

ArgumentException

source is not readable or held no bytes.

OperationCanceledException

ct was cancelled.

DocumentConversionException

It could not be converted.

ConvertWithReport(byte[])

Converts the .docx in docx and reports what the conversion could not carry across.

ConversionResult<string> ConvertWithReport(byte[] docx)

Parameters

docx byte[]

Returns

ConversionResult<string>

Remarks

Convert(byte[]) returns the same Markdown.

Exceptions

ArgumentNullException

docx is null.

ArgumentException

docx is empty.

DocumentConversionException

It could not be converted.

ConvertWithReportAsync(Stream, CancellationToken)

Reads a .docx from source and converts it, reporting what the conversion could not carry across. source is read to its end and is not disposed, closed or sought.

Task<ConversionResult<string>> ConvertWithReportAsync(Stream source, CancellationToken ct = default)

Parameters

source Stream
ct CancellationToken

Returns

Task<ConversionResult<string>>

Exceptions

ArgumentNullException

source is null.

ArgumentException

source is not readable or held no bytes.

OperationCanceledException

ct was cancelled.

DocumentConversionException

It could not be converted.