Click or drag to resize
Pdf Library for .NET

HtmlToPdfConvertHtmlStringAsync(String, String) Method

Asynchronously renders the specified HTML string, resolving relative resources against the given base 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> ConvertHtmlStringAsync(
	string htmlString,
	string baseUrl
)

Parameters

htmlString  String
The HTML content to convert. Cannot be null.
baseUrl  String
The base URL used to resolve relative paths (images, style sheets, scripts) referenced by the HTML. May be null when the HTML has no relative resources.

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 htmlString is null or when the conversion fails.
InvalidOperationException The task faults with this exception when this converter is already running a conversion.
Remarks
The conversion produces the same document as ConvertHtmlString(String, String), without holding a thread while the HTML renders; see ConvertUrlAsync(String).
See Also