Click or drag to resize
Pdf Library for .NET

HtmlToPdfConvertUrlAsync(String) Method

Asynchronously renders the web page at the specified URL and returns the result as a PDF document.

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntax
public Task<PdfDocument> ConvertUrlAsync(
	string url
)

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
ExceptionCondition
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.

Example
HtmlToPdf converter = new HtmlToPdf();
PdfDocument doc = await converter.ConvertUrlAsync("https://selectpdf.com");
doc.Save("selectpdf.pdf");
doc.Close();
See Also