Interface IMarkdownToPdfConverter
- Namespace
- DocToolkit.Extensions.DependencyInjection
- Assembly
- DocToolkit.Extensions.DependencyInjection.dll
Converts Markdown to PDF by way of DOCX. Registered by AddDocToolkit(IServiceCollection, Action<DocToolkitOptions>?).
public interface IMarkdownToPdfConverter
Remarks
A composition of IMarkdownToDocxConverter and IDocxToPdfConverter, exactly as IHtmlToPdfConverter pivots through DOCX. Everything the Markdown importer guarantees carries over unchanged, because this performs no conversion of its own: nothing here reaches the network or the disk.
The fidelity caveats of DOCX → PDF apply.
Methods
Convert(string)
Converts markdown to a PDF.
byte[] Convert(string markdown)
Parameters
markdownstring
Returns
- byte[]
Exceptions
- ArgumentNullException
markdownis null.- DocumentConversionException
It could not be converted.
ConvertAsync(string, Stream, CancellationToken)
Converts markdown and writes the PDF to destination.
The PDF reaches the destination as it is produced rather than being assembled in full
first; the stream is written but neither disposed, closed nor sought.
Task ConvertAsync(string markdown, Stream destination, CancellationToken ct = default)
Parameters
markdownstringdestinationStreamctCancellationToken
Returns
Exceptions
- ArgumentNullException
Either argument is null.
- ArgumentException
destinationis not writable.- OperationCanceledException
ctwas cancelled.- DocumentConversionException
It could not be converted or written.
ConvertWithReport(string)
Converts markdown and reports what the conversion could not carry
across.
ConversionResult<byte[]> ConvertWithReport(string markdown)
Parameters
markdownstring
Returns
Remarks
The warnings come from the Markdown → DOCX half only. The DOCX → PDF half renders rather than converts and produces no report, so a caveat that applies to it will not appear here.
Exceptions
- ArgumentNullException
markdownis null.- DocumentConversionException
It could not be converted.