 |
HtmlToPdfConvertUrlAsync(String) Method |
Asynchronously renders the web page at the specified URL and returns the result as a PDF document.
Namespace: SelectPdf.UniversalAssembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntaxpublic Task<PdfDocument> ConvertUrlAsync(
string url
)
Public Function ConvertUrlAsync (
url As String
) As Task(Of PdfDocument)
Parameters
- url String
- The absolute URL of the web page to convert. Cannot be null or empty.
Return Value
TaskPdfDocument
A task that completes with a
PdfDocument containing the converted content. The
caller is responsible for saving and closing the returned document.
Exceptions| Exception | Condition |
|---|
| HtmlToPdfException |
The task faults with this exception when url is null or empty, or when the
conversion fails (for example an unreachable host, a navigation timeout or a proxy error).
|
| InvalidOperationException |
The task faults with this exception when this converter is already running a conversion.
|
Remarks
The conversion produces the same document as ConvertUrl(String). While the page
loads and renders, no thread is held waiting for it, so a server can have many conversions in
flight without a thread for each. Conversions started together render at the same time, up to
MaximumConcurrentConversions; the ones past that limit wait for
their turn in the order they were started, in the same queue as the synchronous calls.
One HtmlToPdf instance runs one conversion at a time. To convert several pages at
once, use one converter for each.
ExampleHtmlToPdf converter = new HtmlToPdf();
PdfDocument doc = await converter.ConvertUrlAsync("https://selectpdf.com");
doc.Save("selectpdf.pdf");
doc.Close();Dim converter As New HtmlToPdf()
Dim doc As PdfDocument = Await converter.ConvertUrlAsync("https://selectpdf.com")
doc.Save("selectpdf.pdf")
doc.Close()
See Also