 |
HtmlToPdfConvertHtmlStringAsync(String) Method |
Asynchronously renders the specified HTML string and returns the result as a PDF document.
Namespace: SelectPdf.UniversalAssembly: SelectPdf.HtmlToPdf.Universal (in SelectPdf.HtmlToPdf.Universal.dll) Version: 26.4
Syntaxpublic Task<PdfDocument> ConvertHtmlStringAsync(
string htmlString
)
Public Function ConvertHtmlStringAsync (
htmlString As String
) As Task(Of PdfDocument)
Parameters
- htmlString String
- The HTML content to convert. Cannot be null.
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 htmlString is null or when the
conversion fails.
|
| InvalidOperationException |
The task faults with this exception when this converter is already running a conversion.
|
Remarks
ExampleHtmlToPdf converter = new HtmlToPdf();
PdfDocument doc =
await converter.ConvertHtmlStringAsync("<h1>Hello World</h1>");
doc.Save("hello.pdf");
doc.Close();Dim converter As New HtmlToPdf()
Dim doc As PdfDocument =
Await converter.ConvertHtmlStringAsync("<h1>Hello World</h1>")
doc.Save("hello.pdf")
doc.Close()
See Also