Table of Contents

Interface IDocxToPdfConverter

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

Renders a Word (.docx) package to PDF. Registered by AddDocToolkit(IServiceCollection, Action<DocToolkitOptions>?).

public interface IDocxToPdfConverter

Methods

Convert(byte[])

Renders the .docx in docx and returns PDF bytes.

byte[] Convert(byte[] docx)

Parameters

docx byte[]

Returns

byte[]

Exceptions

ArgumentNullException

docx is null.

ArgumentException

docx is empty.

DocumentConversionException

The DOCX could not be rendered.

ConvertAsync(Stream, Stream, CancellationToken)

Reads a .docx from source and writes the rendered PDF to destination. Neither stream is disposed, closed, sought or read back; the PDF is written straight through as the renderer produces it, so nothing here ever holds the whole rendered document in memory. The consequence of streaming is that a failure part-way through leaves whatever had already been produced on destination.

Task ConvertAsync(Stream source, Stream destination, CancellationToken ct = default)

Parameters

source Stream
destination Stream
ct CancellationToken

Returns

Task

Exceptions

ArgumentNullException

Either stream is null.

ArgumentException

source is not readable or held no bytes, or destination is not writable.

OperationCanceledException

ct was cancelled.

DocumentConversionException

The DOCX could not be rendered.