ImgConverterGetImageBytesFromUrlAsync Method |
Converts the specified URL into an image asynchronously and returns the image as an array of bytes in the specified format.
Namespace: ExpertPdf.HtmlToPdfAssembly: ephtmltopdf (in ephtmltopdf.dll) Version: 22.0.0
Syntaxpublic Task<byte[]> GetImageBytesFromUrlAsync(
string url,
ImageFormat format,
CancellationToken cancellationToken = default
)
Public Function GetImageBytesFromUrlAsync (
url As String,
format As ImageFormat,
Optional cancellationToken As CancellationToken = Nothing
) As Task(Of Byte())
Parameters
- url String
- The URL of the web page to be converted. The URL can be also the full path
of a HTML file from the local file system.
- format ImageFormat
- The image format.
- cancellationToken CancellationToken (Optional)
- A token that cancels the wait for the conversion.
Return Value
TaskByteA task whose result is the image bytes.
Remarks
The conversion runs on a thread of its own, so the calling thread is free while the page loads and renders. Cancelling the
token completes the task as canceled right away; the conversion already started is not interrupted, it ends on its own (it
is limited by
NavigationTimeout and
MaxConversionTime) and its result is discarded.
Do not change the converter, or start another conversion with it, before the task completes.
These methods are not available in the .NET Framework 2.0 build of the library.
See Also