Table of Contents

Interface IDocxToHtmlConverter

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

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

The result is a complete HTML document, not a fragment, and is self-contained - images come back as data: URIs.

public interface IDocxToHtmlConverter

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 HTML. A plain DOCX reports at least one entry today - SectionLayoutFlattened, an approximation of section page geometry - so this is not a channel that only speaks up in unusual cases.

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.