Table of Contents

Interface IMarkdownToDocxConverter

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

Converts Markdown to a Word (.docx) package, completing the round trip IDocxToMarkdownConverter opens. Registered by AddDocToolkit(IServiceCollection, Action<DocToolkitOptions>?).

public interface IMarkdownToDocxConverter

Remarks

Nothing here reaches the network or the disk. A remote image reference becomes a hyperlink rather than a fetch, and a local file reference is refused - reading a path out of untrusted document content would let the document choose which file gets embedded in the output. data: images are inlined, since they carry their own bytes.

There is no Stream source overload, here or on the static API: the input is a string rather than a document, so a caller holding bytes decides their own encoding.

Methods

Convert(string)

Converts markdown to a .docx package.

byte[] Convert(string markdown)

Parameters

markdown string

Returns

byte[]

Exceptions

ArgumentNullException

markdown is null.

DocumentConversionException

It could not be converted.

ConvertAsync(string, Stream, CancellationToken)

Converts markdown and writes the .docx to destination, which is written but neither disposed, closed nor sought.

Task ConvertAsync(string markdown, Stream destination, CancellationToken ct = default)

Parameters

markdown string
destination Stream
ct CancellationToken

Returns

Task

Exceptions

ArgumentNullException

Either argument is null.

ArgumentException

destination is not writable.

OperationCanceledException

ct was cancelled.

DocumentConversionException

It could not be converted.

ConvertWithReport(string)

Converts markdown and reports what the conversion could not carry across. Convert(string) produces the same document.

ConversionResult<byte[]> ConvertWithReport(string markdown)

Parameters

markdown string

Returns

ConversionResult<byte[]>

Exceptions

ArgumentNullException

markdown is null.

DocumentConversionException

It could not be converted.