Click or drag to resize
Pdf Library for .NET

HtmlToImageConvertHtmlStringAsync(String) Method

Asynchronously converts the specified HTML string to an image in ImageFormat (PNG by default).

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntax
public Task<byte[]> ConvertHtmlStringAsync(
	string htmlString
)

Parameters

htmlString  String
The HTML markup to render.

Return Value

TaskByte
A task that completes with the rendered image, encoded in ImageFormat.
Exceptions
ExceptionCondition
HtmlToPdfExceptionThe task faults with this exception when htmlString is null, or the conversion fails.
Remarks
The conversion produces the same image as ConvertHtmlString(String), without holding a thread while the HTML renders.
Example
SelectPdf.Universal.HtmlToImage converter = new SelectPdf.Universal.HtmlToImage();
byte[] png = await converter.ConvertHtmlStringAsync("<h1>Hello</h1>");
See Also