Click or drag to resize
Pdf Library for .NET

HtmlToPdfConvertHtmlString Method (String)

Gets a PdfDocument object representing the result of the conversion of the specified html string to pdf.

Namespace:  SelectPdf
Assembly:  Select.Pdf (in Select.Pdf.dll) Version: 20.2
Syntax
public PdfDocument ConvertHtmlString(
	string htmlString
)

Parameters

htmlString
Type: SystemString
The html string to be converted to pdf.

Return Value

Type: PdfDocument
The PdfDocument object that can be modified and saved to a file, to a stream, to a memory buffer or to a HTTP response.
Remarks
The resulted PdfDocument object can be modified and saved to a file, to a stream, to a memory buffer or to a HTTP response. The PdfDocument object must be closed after save to release the system resources used during conversion.

This method does not use any base url and therefore the images or css files referenced by relative urls in the html string cannot be resolved by the converter to an absolute url. If there are external resources referenced by relative urls, the ConvertHtmlString(String, String) method with the baseUrl additional parameter should be used.

Examples
The following sample code shows how an HtmlToPdf Converter can be instantiated and a basic conversion performed.
HtmlToPdf converter = new HtmlToPdf();
PdfDocument doc = converter.ConvertHtmlString(html);
doc.Save(file);
doc.Close();
See Also