HtmlConverter Class
Class which allows converting Html to the Image.
Inheritance
Namespace: Syncfusion.HtmlConverter
Assembly: Syncfusion.HtmlConverter.Base.dll
Syntax
public class HtmlConverter : UserControl, IDocHostUIHandler, IDocHostShowUI, IOleClientSite, IServiceProvider, IAuthenticate, IInternetSecurityManager
Constructors
HtmlConverter()
Initializes a new instance of the HtmlConverter class.
Declaration
public HtmlConverter()
HtmlConverter(IHtmlRenderer)
Initializes a new instance of the HtmlConverter class with specified HTML renderer.
Declaration
public HtmlConverter(IHtmlRenderer renderer)
Parameters
Type | Name | Description |
---|---|---|
IHtmlRenderer | renderer | Specifies the HTML renderer. |
Properties
AdditionalDelay
Gets or Sets a value to delay the script loading.
Declaration
public int AdditionalDelay { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | A integer value indicating to apply delay for loading scripts.Unit is Milliseconds; By default 0 |
AutoDetectPageBreak
Gets or Sets a value indicating whether to auto-detect page-break in the webpage.
Declaration
public bool AutoDetectPageBreak { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if Page break is enabled, otherwise, |
BackgroundColor
Gets or sets a background color when converting a HTML document.
Declaration
[Obsolete("Please use BackgroundColor in WebKitConverterSettings class instead")]
public Color BackgroundColor { get; set; }
Property Value
Type |
---|
System.Drawing.Color |
ClearInternetCache
Gets or sets a value indicating whether to clear Internet cache.
Declaration
public bool ClearInternetCache { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the internetcache clears , otherwise false. |
Cookies
Gets or sets cookie collection with names and values
Declaration
[Obsolete("Please use Cookies in WebKitConverterSettings class instead")]
public CookieCollection Cookies { get; set; }
Property Value
Type | Description |
---|---|
CookieCollection | The cookies Collection |
See Also
DisableIEWarning
Sets a value that indicates whether to remove the IE engine warning or not. The default value is false.
Declaration
public bool DisableIEWarning { set; }
Property Value
Type |
---|
System.Boolean |
EnableActiveXContents
Gets or Sets a value indicating whether to Enable/Disable Javascript in the web page.
Declaration
public bool EnableActiveXContents { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if ActiveXContents enabled, otherwise false. Default is false |
EnableBinaryBehaviors
Gets or Sets a value indicating whether to Enable/Disable binary behaviors in the webpage.
Declaration
public bool EnableBinaryBehaviors { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
EnableBookmarks
A property indicating if the automatic creation of bookmarks in PDF for the H1 to H6 HTML elements is enabled or not. By default the automatic bookmarks creation is disabled
Declaration
[Obsolete("Please use EnableBookmarks in WebKitConverterSettings class instead")]
public bool EnableBookmarks { get; set; }
Property Value
Type |
---|
System.Boolean |
EnableDirectLayout
While enabling this property the text and images will be split across pages even if SplitTextLines and SplitImages were set to false.
Declaration
public bool EnableDirectLayout { get; set; }
Property Value
Type |
---|
System.Boolean |
EnableForm
Declaration
public bool EnableForm { get; set; }
Property Value
Type |
---|
System.Boolean |
EnableHyperlinks
Gets or Sets a value indicating whether to preserve the live-links in the converted document or not.
Declaration
public bool EnableHyperlinks { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the Hyperlinks are enabled, otherwise false.Default is true |
EnableJavaScript
Gets or Sets a value indicating whether to Enable/Disable Javascripts in the webpage.
Declaration
public bool EnableJavaScript { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if Javascript is enabled, otherwise,false. default is true |
EnableRepeatTableFooter
Gets or sets the repetition of table footer. By enabling this property, will repeat the table footer on every page break. The default value is false.
Declaration
[Obsolete("Please use EnableRepeatTableFooter in WebKitConverterSettings class instead")]
public bool EnableRepeatTableFooter { get; set; }
Property Value
Type |
---|
System.Boolean |
EnableRepeatTableHeader
Gets or sets the repetition of table header. By enabling this property, will repeat the table header on every page break. The default value is false.
Declaration
[Obsolete("Please use EnableRepeatTableHeader in WebKitConverterSettings class instead")]
public bool EnableRepeatTableHeader { get; set; }
Property Value
Type |
---|
System.Boolean |
EnableToc
A property indicating if the automatic creation of a table of contents items for the H1 to H6 HTML elements is enabled or not. By default this property is false
Declaration
[Obsolete("Please use EnableToc in WebKitConverterSettings class instead")]
public bool EnableToc { get; set; }
Property Value
Type |
---|
System.Boolean |
HtmlEncoding
Gets or sets Encoding for HTML string to PDF conversion.
Declaration
public Encoding HtmlEncoding { get; set; }
Property Value
Type |
---|
System.Text.Encoding |
Remarks
This property will not have any effect on URL to PDF conversion
Password
Gets or Sets the password
Declaration
public string Password { get; set; }
Property Value
Type | Description |
---|---|
System.String | String value representing the password of the HTML document. |
Timeout
Set the maximum time in milliseconds to wait for HTML page to be loaded;
Declaration
public int Timeout { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | Specifies the timeout to the HTML converter.Unit is Milliseconds; By default 0 |
Toc
Gets or sets Toc styles
Declaration
[Obsolete("Please use Toc in WebKitConverterSettings class instead")]
public HtmlToPdfToc Toc { get; set; }
Property Value
Type |
---|
HtmlToPdfToc |
Username
Gets or Sets the Username
Declaration
public string Username { get; set; }
Property Value
Type | Description |
---|---|
System.String | String value representing the user name of the HTML document. |
Methods
Authenticate(ref IntPtr, ref IntPtr, ref IntPtr)
Declaration
public int Authenticate(ref IntPtr phwnd, ref IntPtr pszUsername, ref IntPtr pszPassword)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | phwnd | |
System.IntPtr | pszUsername | |
System.IntPtr | pszPassword |
Returns
Type |
---|
System.Int32 |
Convert(String, ImageType, Int32, Int32, AspectRatio)
Converts HTML to HtmlToPdfElement result.
Declaration
public HtmlToPdfResult Convert(string url, ImageType type, int width, int height, AspectRatio aspectRatio)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | |
ImageType | type | Specifies the image type |
System.Int32 | width | Integer value specifying the width of the web browser |
System.Int32 | height | Integer value specifying the height of the web browser |
AspectRatio | aspectRatio | Representing dimension of the image. |
Returns
Type | Description |
---|---|
HtmlToPdfResult | Converted image. |
Convert(String, ImageType, Int32, Int32, AspectRatio, String, String)
Converts HTML to HtmlToPdfElement result.
Declaration
public HtmlToPdfResult Convert(string url, ImageType type, int width, int height, AspectRatio aspectRatio, string username, string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | |
ImageType | type | Specifies the image type |
System.Int32 | width | Integer value specifying the width of the web browser |
System.Int32 | height | Integer value specifying the height of the web browser |
AspectRatio | aspectRatio | Representing dimension of the image. |
System.String | username | |
System.String | password |
Returns
Type | Description |
---|---|
HtmlToPdfResult | Converted image. |
Convert(String, String, ImageType, Int32, Int32, AspectRatio)
Converts the given HTML string to HtmlToPdfResult.
Declaration
public HtmlToPdfResult Convert(string html, string baseurl, ImageType type, int width, int height, AspectRatio aspectRatio)
Parameters
Type | Name | Description |
---|---|---|
System.String | html | HTML data. |
System.String | baseurl | |
ImageType | type | Specifies the image type |
System.Int32 | width | Integer value specifying the width of the web browser |
System.Int32 | height | Integer value specifying the height of the web browser |
AspectRatio | aspectRatio | Representing dimension of the image. |
Returns
Type | Description |
---|---|
HtmlToPdfResult | Converted image. |
ConvertToImage(Stream, Encoding, ImageType)
Converts Html data contained in the stream to the image.
Declaration
public Image ConvertToImage(Stream stream, Encoding encoding, ImageType type)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Stream containing HTML data. |
System.Text.Encoding | encoding | Encoding used for reading data from the stream. |
ImageType | type | Type of the output image. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
Remarks
If the stream can seek, the position will be set to 0 before data reading.
ConvertToImage(Stream, Encoding, ImageType, Int32)
Converts HTML data contained in the stream to the image.
Declaration
public Image ConvertToImage(Stream stream, Encoding encoding, ImageType type, int width)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Stream containing HTML data. |
System.Text.Encoding | encoding | Encoding used for reading data from the stream. |
ImageType | type | Type of the output image. |
System.Int32 | width | Preferred width of the image in pixels. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
Remarks
If the stream can seek, the position will be set to 0 before data reading.
ConvertToImage(Stream, Encoding, ImageType, Int32, Int32)
Converts HTML data contained in the stream to the image.
Declaration
public Image ConvertToImage(Stream stream, Encoding encoding, ImageType type, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Stream containing HTML data. |
System.Text.Encoding | encoding | Encoding used for reading data from the stream. |
ImageType | type | Type of the output image. |
System.Int32 | width | Preferred width of the image in pixels. |
System.Int32 | height | Preferred height of the image in pixels. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
Remarks
If the stream can seek, the position will be set to 0 before data reading.
ConvertToImage(Stream, Encoding, ImageType, Int32, Int32, AspectRatio)
Converts HTML data contained in the stream to the image.
Declaration
public Image ConvertToImage(Stream stream, Encoding encoding, ImageType type, int width, int height, AspectRatio aspectRatio)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Stream containing HTML data. |
System.Text.Encoding | encoding | Encoding used for reading data from the stream. |
ImageType | type | Type of the output image. |
System.Int32 | width | Preferred width of the image in pixels. |
System.Int32 | height | Preferred height of the image in pixels. |
AspectRatio | aspectRatio | Aspect ratio of the image. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
Remarks
If the stream can seek, the position will be set to 0 before data reading.
ConvertToImage(String, ImageType)
Converts HTML by the URL to the image.
Declaration
public Image ConvertToImage(string url, ImageType type)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Path to the HTML resource. |
ImageType | type | Type of the output image. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
ConvertToImage(String, ImageType, Int32)
Converts HTML by the URL to the image.
Declaration
public Image ConvertToImage(string url, ImageType type, int width)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Path to the HTML resource. |
ImageType | type | Type of the output image. |
System.Int32 | width | Preferred width of the image in pixels. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
ConvertToImage(String, ImageType, Int32, Int32)
Converts HTML by the URL to the image.
Declaration
public Image ConvertToImage(string url, ImageType type, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Path to the HTML resource. |
ImageType | type | Type of the output image. |
System.Int32 | width | Preferred width of the image in pixels. |
System.Int32 | height | Preferred height of the image in pixels. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
Remarks
Image height can be greater than
ConvertToImage(String, ImageType, Int32, Int32, AspectRatio)
Converts HTML by the URL to the image.
Declaration
public Image ConvertToImage(string url, ImageType type, int width, int height, AspectRatio aspectRatio)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Path to the HTML resource. |
ImageType | type | Type of the output image. |
System.Int32 | width | Preferred width of the image in pixels. |
System.Int32 | height | Preferred height of the image in pixels. |
AspectRatio | aspectRatio | Aspect ratio of the image. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
Remarks
Image height can be greater than
ConvertToImage(String, ImageType, Int32, Int32, AspectRatio, String, String)
Converts HTML by the URL to the image.
Declaration
public Image ConvertToImage(string url, ImageType type, int width, int height, AspectRatio aspectRatio, string username, string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Path to the HTML resource. |
ImageType | type | Type of the output image. |
System.Int32 | width | Preferred width of the image in pixels. |
System.Int32 | height | Preferred height of the image in pixels. |
AspectRatio | aspectRatio | Aspect ratio of the image. |
System.String | username | The User name. |
System.String | password | The Password. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
Remarks
Image height can be greater than
ConvertToImage(String, ImageType, Int32, Int32, String, String)
Converts HTML by the URL to the image.
Declaration
public Image ConvertToImage(string url, ImageType type, int width, int height, string username, string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Path to the HTML resource. |
ImageType | type | Type of the output image. |
System.Int32 | width | Preferred width of the image in pixels. |
System.Int32 | height | Preferred height of the image in pixels. |
System.String | username | The User name. |
System.String | password | The Password. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
Remarks
Image height can be greater than
ConvertToImage(String, ImageType, Int32, String, String)
Converts HTML by the URL to the image.
Declaration
public Image ConvertToImage(string url, ImageType type, int width, string username, string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Path to the HTML resource. |
ImageType | type | Type of the output image. |
System.Int32 | width | Preferred width of the image in pixels. |
System.String | username | The User name. |
System.String | password | The Password. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
ConvertToImage(String, ImageType, String, String)
Converts HTML by the URL to the image.
Declaration
public Image ConvertToImage(string url, ImageType type, string username, string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Path to the HTML resource. |
ImageType | type | Type of the output image. |
System.String | username | The User name. |
System.String | password | The Password. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
ConvertToTaggedPDF(PdfDocument, String)
Converts the URL as Tagged PDF.
Declaration
public PdfLayoutResult ConvertToTaggedPDF(PdfDocument document, string url)
Parameters
Type | Name | Description |
---|---|---|
PdfDocument | document | The PDF document |
System.String | url | Path to the HTML resource. |
Returns
Type | Description |
---|---|
PdfLayoutResult | The layout result of the PDF document |
ConvertToTaggedPDF(PdfDocument, String, String)
Converts the HTML string as Tagged PDF.
Declaration
public PdfLayoutResult ConvertToTaggedPDF(PdfDocument document, string html, string baseURL)
Parameters
Type | Name | Description |
---|---|---|
PdfDocument | document | The PDF document |
System.String | html | Path to the HTML resource. |
System.String | baseURL | Used to retrieve images, scripts and stylesheets. |
Returns
Type | Description |
---|---|
PdfLayoutResult | The layout result of the PDF document |
ConvertToTaggedPDF(PdfDocument, String, String, String)
Declaration
public PdfLayoutResult ConvertToTaggedPDF(PdfDocument document, string url, string userName, string password)
Parameters
Type | Name | Description |
---|---|---|
PdfDocument | document | |
System.String | url | |
System.String | userName | |
System.String | password | The Password. |
Returns
Type | Description |
---|---|
PdfLayoutResult | The layout result of the PDF document |
CustomizeDownload()
Applies download and executing properties.
Declaration
public int CustomizeDownload()
Returns
Type | Description |
---|---|
System.Int32 | Settings flag. |
Remarks
Don't call this method. It's used for internal purpose only.
Dispose(Boolean)
Disposes component.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Indicates whether dispose managed resources or not. |
FromString(String, ImageType, Int32)
Renders HTML from the string to the image.
Declaration
public Image FromString(string html, ImageType type, int width)
Parameters
Type | Name | Description |
---|---|---|
System.String | html | HTML data. |
ImageType | type | Type of the image. |
System.Int32 | width | Preferred width of the image. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
FromString(String, ImageType, Int32, Int32)
Renders HTML from the string to the image.
Declaration
public Image FromString(string html, ImageType type, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
System.String | html | HTML data. |
ImageType | type | Type of the image. |
System.Int32 | width | Preferred width of the image. |
System.Int32 | height | Preferred height of the image. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
FromString(String, ImageType, Int32, Int32, AspectRatio)
Renders HTML from the string to the image.
Declaration
public Image FromString(string html, ImageType type, int width, int height, AspectRatio aspectRatio)
Parameters
Type | Name | Description |
---|---|---|
System.String | html | HTML data. |
ImageType | type | Type of the image. |
System.Int32 | width | Preferred width of the image. |
System.Int32 | height | Preferred height of the image. |
AspectRatio | aspectRatio | Aspect ratio of the image. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
FromString(String, String, ImageType)
Renders HTML from the string to the image.
Declaration
public Image FromString(string html, string baseUrl, ImageType type)
Parameters
Type | Name | Description |
---|---|---|
System.String | html | HTML data. |
System.String | baseUrl | Used to retrieve images, scripts and stylesheets. |
ImageType | type | Type of the image. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
FromString(String, String, ImageType, Int32)
Renders HTML from the string to the image.
Declaration
public Image FromString(string html, string baseUrl, ImageType type, int width)
Parameters
Type | Name | Description |
---|---|---|
System.String | html | HTML data. |
System.String | baseUrl | Used to retrieve images, scripts and stylesheets. |
ImageType | type | Type of the image. |
System.Int32 | width | Preferred width of the image. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
FromString(String, String, ImageType, Int32, Int32)
Renders HTML from the string to the image.
Declaration
public Image FromString(string html, string baseUrl, ImageType type, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
System.String | html | HTML data. |
System.String | baseUrl | Used to retrieve images, scripts and stylesheets. |
ImageType | type | Type of the image. |
System.Int32 | width | Preferred width of the image. |
System.Int32 | height | Preferred height of the image. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
FromString(String, String, ImageType, Int32, Int32, AspectRatio)
Renders HTML from the string to the image.
Declaration
public Image FromString(string html, string baseUrl, ImageType type, int width, int height, AspectRatio aspectRatio)
Parameters
Type | Name | Description |
---|---|---|
System.String | html | HTML data. |
System.String | baseUrl | Used to retrieve images, scripts and stylesheets. |
ImageType | type | Type of the image. |
System.Int32 | width | Preferred width of the image. |
System.Int32 | height | Preferred height of the image. |
AspectRatio | aspectRatio | Aspect ratio of the image. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
FromString(String, String, ImageType, Int32, Int32, AspectRatio, String, String)
Renders HTML from the string to the image.
Declaration
public Image FromString(string html, string baseUrl, ImageType type, int width, int height, AspectRatio aspectRatio, string username, string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | html | HTML data. |
System.String | baseUrl | Used to retrieve images, scripts and stylesheets. |
ImageType | type | Type of the image. |
System.Int32 | width | Preferred width of the image. |
System.Int32 | height | Preferred height of the image. |
AspectRatio | aspectRatio | Aspect ratio of the image. |
System.String | username | The User name. |
System.String | password | The Password. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Image, containing data from the HTML. |
GetImagesFromString(String, String, ImageType)
Renders HTML from the string to the image.
Declaration
public Image[] GetImagesFromString(string html, string baseUrl, ImageType type)
Parameters
Type | Name | Description |
---|---|---|
System.String | html | HTML data. |
System.String | baseUrl | Used to retrieve images, scripts and stylesheets. |
ImageType | type | Type of the image. |
Returns
Type | Description |
---|---|
System.Drawing.Image[] | Image, containing data from the HTML. |
QueryService(ref Guid, ref Guid, out IntPtr)
Declaration
public int QueryService(ref Guid guidService, ref Guid riid, out IntPtr ppvObject)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | guidService | |
System.Guid | riid | |
System.IntPtr | ppvObject |
Returns
Type |
---|
System.Int32 |