Click or drag to resize
Pdf Library for .NET

HtmlToPdfConvertHtmlString(String) Method

Renders the specified HTML string and returns the result as a PDF document.

Namespace: SelectPdf.Universal
Assembly: SelectPdf.HtmlToPdf.Universal (in SelectPdf.HtmlToPdf.Universal.dll) Version: 26.4
Syntax
public PdfDocument ConvertHtmlString(
	string htmlString
)

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
ExceptionCondition
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.
Example
HtmlToPdf converter = new HtmlToPdf();
PdfDocument doc = converter.ConvertHtmlString("<h1>Hello World</h1>");
doc.Save("hello.pdf");
doc.Close();
See Also