 |
HtmlToImageConvertHtmlStringAsync(String, String, CancellationToken) Method |
Asynchronously converts the specified HTML string to an image in
ImageFormat (PNG by default), resolving relative urls against the base url and stopping when the specified token is cancelled.
Namespace: SelectPdf.UniversalAssembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntaxpublic Task<byte[]> ConvertHtmlStringAsync(
string htmlString,
string baseUrl,
CancellationToken cancellationToken
)
Public Function ConvertHtmlStringAsync (
htmlString As String,
baseUrl As String,
cancellationToken As CancellationToken
) As Task(Of Byte())
Parameters
- htmlString String
- The HTML markup to render.
- baseUrl String
- The base url used to resolve relative resource references (images, CSS) in the markup.
- cancellationToken CancellationToken
- A token that stops the conversion when it is cancelled.
Return Value
TaskByteA task that completes with the rendered image, encoded in
ImageFormat.
Exceptions| Exception | Condition |
|---|
| HtmlToPdfException | The task faults with this exception when htmlString is null, or the conversion fails. |
| OperationCanceledException | The task is cancelled when cancellationToken is cancelled before the conversion completes. |
Remarks
The conversion produces the same image as
ConvertHtmlString(String, String), without
holding a thread while the HTML renders. Cancelling the token stops the conversion, and the task then
ends cancelled.
See Also