Click or drag to resize

HTML to Image Converter Element

The integrated HTML to Image Converter is implemented by the HtmlToImageElement graphic element. It offers the possibility to specify the position and the size of the PDF content rendered from HTML and the possibility to add many HTML to Image conversions to same document.

A very useful feature is the possibility to know the size of the rendered content in each page when the rendered content spans on many pages. The information about the last rendered page can be taken from the AddElementResult object returned after adding the element to a renderer like a page or template.

The HtmlToImageElement offer many constructors that basically call the following two constructors with more or less default values for converting a URL or a HTML string to Image:

public HtmlToImageElement(float x, float y, float width, float height, 
    string urlToConvert, int htmlViewerWidth, int htmlViewerHeight);

   public HtmlToImageeElement(float x, float y, float width, float height, 
    string htmlStringToConvert, string htmlStringBaseURL,
    int htmlViewerWidth, int htmlViewerHeight);

The various constructor parameters are explined below.

The first constructor creates a URL to Image converter element at the specified x and y coordinates with the specified width and height. The virtual browser width and height in pixels are specified by the htmlViewerWidth and htmlViewerHeight parameters.

  • x - The x position in points where the rendered content will be placed.

  • y - The y position in points where the rendered content will be placed.

  • width - The destination width in points for the rendered content. If the specified with is negative, the destination width will be given by the available width in page or template.

  • height - The destination height in points for the rendered content. If the specified height is negative, the destination height will be auto determined so all the content can be rendered. Please note that the specified height is the effective height that will be rendered in the PDF document and does not include for example the empty spaces introduced by custom or automatic page breaks.

  • urlToConvert - The URL to convert to PDF.

  • htmlViewerWidth - The virtual browser width in pixels. The default value is 1024 pixels. The effect of this parameter is similar with viewing the HTML page in a browser window with the specified width. When this parameter is negative, the converter will try to auto-determine the HTML page width from the HTML body element width.

  • htmlViewerHeight - The virtual browser height in pixels. The default value is 0 which means the height will be auto-determined. The effect of this parameter is similar with viewing the HTML page in a browser window with the specified width and height. When this parameter is negative, the converter will try to auto-determine the HTML page height from the HTML body element height.

The second constructor creates a HTML string to Image converter element at the specified x and y coordinates with the specified width and height. The virtual browser width and height in pixels is specified by the htmlViewerWidth and htmlViewerHeight parameters.

  • htmlStringToConvert - The HTML string converted to PDF.

  • htmlStringBaseURL - The full URL of the page from where this string was taken used to resolve the images and CSS files referenced by a relative URL in the HTML string. This parameter is optional and the default value is NULL. When this parameter is NULL no base URL will be used.