Interface IHtmlToDocxConverter
- Namespace
- DocToolkit.Extensions.DependencyInjection
- Assembly
- DocToolkit.Extensions.DependencyInjection.dll
Converts HTML to a Word (.docx) package. Registered by AddDocToolkit(IServiceCollection, Action<DocToolkitOptions>?); remote image download is controlled once, at registration, via AllowRemoteImageDownload, and bounded by RemoteImage.
public interface IHtmlToDocxConverter
Methods
ConvertAsync(string, PageSetup, Stream, CancellationToken)
As above, laid out on page rather than the A4 default.
Task ConvertAsync(string html, PageSetup page, Stream destination, CancellationToken ct = default)
Parameters
htmlstringThe markup to convert.
pagePageSetupThe page size, orientation and margins.
destinationStreamThe stream the result is written to.
ctCancellationTokenCancels the conversion and the write.
Returns
Exceptions
- ArgumentNullException
Any argument is null.
- ArgumentException
destinationis not writable.- OperationCanceledException
ctwas cancelled.- DocumentConversionException
The HTML could not be converted.
ConvertAsync(string, PageSetup, CancellationToken)
As above, laid out on page rather than the A4 default.
Task<byte[]> ConvertAsync(string html, PageSetup page, CancellationToken ct = default)
Parameters
htmlstringThe markup to convert.
pagePageSetupThe page size, orientation and margins.
ctCancellationTokenCancels the conversion.
Returns
Exceptions
- ArgumentNullException
htmlorpageis null.- OperationCanceledException
ctwas cancelled.- DocumentConversionException
The HTML could not be converted.
ConvertAsync(string, Stream, CancellationToken)
Converts html and writes the .docx to destination.
destination is written, from its current position, and is
not disposed, closed or sought.
Task ConvertAsync(string html, Stream destination, CancellationToken ct = default)
Parameters
htmlstringdestinationStreamctCancellationToken
Returns
Exceptions
- ArgumentNullException
htmlordestinationis null.- ArgumentException
destinationis not writable.- OperationCanceledException
ctwas cancelled.- DocumentConversionException
The HTML could not be converted or written.
ConvertAsync(string, CancellationToken)
Converts html to the bytes of a .docx package.
Task<byte[]> ConvertAsync(string html, CancellationToken ct = default)
Parameters
htmlstringctCancellationToken
Returns
Exceptions
- ArgumentNullException
htmlis null.- OperationCanceledException
ctwas cancelled.- DocumentConversionException
The HTML could not be converted.