 |
HtmlToPdfConvertHtmlString(String) Method |
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 PdfDocument ConvertHtmlString(
string htmlString
)
Public Function ConvertHtmlString (
htmlString As String
) As PdfDocument
Parameters
- htmlString String
- The HTML content to convert. Cannot be null.
Return Value
PdfDocument
A
PdfDocument containing the converted content. The caller is responsible
for saving and closing the returned document.
Exceptions| Exception | Condition |
|---|
| HtmlToPdfException |
Thrown when htmlString is null or when the conversion fails.
|
Remarks
Relative resources (images, style sheets, scripts) referenced by the HTML are not resolved.
Use
ConvertHtmlString(String, String) and supply a base URL to resolve them.
ExampleHtmlToPdf converter = new HtmlToPdf();
PdfDocument doc = converter.ConvertHtmlString("<h1>Hello World</h1>");
doc.Save("hello.pdf");
doc.Close();Dim converter As New HtmlToPdf()
Dim doc As PdfDocument = converter.ConvertHtmlString("<h1>Hello World</h1>")
doc.Save("hello.pdf")
doc.Close()
See Also