 |
HtmlToImageConvertUrlAsync(String, CancellationToken) Method |
Asynchronously converts the web page at the specified url to an image in
ImageFormat (PNG by default), stopping when the specified token is cancelled.
Namespace: SelectPdf.UniversalAssembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntaxpublic Task<byte[]> ConvertUrlAsync(
string url,
CancellationToken cancellationToken
)
Public Function ConvertUrlAsync (
url As String,
cancellationToken As CancellationToken
) As Task(Of Byte())
Parameters
- url String
- The absolute url of the web page to render.
- 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 url is null or empty, 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
ConvertUrl(String), without holding a thread
while the page loads and renders. Cancelling the token stops the conversion in the engine, and the
task then ends cancelled.
See Also