wxRuby Documentation Home

# Wx::HtmlDCRenderer

This class can render HTML document into a specified area of a DC. You can use it
in your own printing code, although use of HtmlEasyPrinting
or HtmlPrintout is strongly recommended.

## Derived from

Object

## Methods

- HtmlDCRenderer.new
- HtmlDCRenderer#set_dc
- HtmlDCRenderer#set_fonts
- HtmlDCRenderer#set_size
- HtmlDCRenderer#set_html_text
- HtmlDCRenderer#render
- HtmlDCRenderer#get_total_height

### HtmlDCRenderer.new

### HtmlDCRenderer#set_dc

set_dc(%(arg-type)DC% dc, Float pixel_scale = 1.0)

Assign DC instance to the renderer.

pixel_scale can be used when rendering to high-resolution DCs (e.g. printer) to adjust size of pixel metrics.
(Many dimensions in HTML are given in pixels — e.g. image sizes. 300×300 image would be only one
inch wide on typical printer. With pixel_scale = 3.0 it would be 3 inches.)

### HtmlDCRenderer#set_fonts

set_fonts(%(arg-type)String% normal_face, String fixed_face, Integer sizes = nil)

Sets fonts. See HtmlWindow#set_fonts for
detailed description.

See also set_size.

### HtmlDCRenderer#set_size

set_size(%(arg-type)Integer% width, Integer height)

Set size of output rectangle, in pixels. Note that you can’t change
width of the rectangle between calls to Render!
(You can freely change height.)

### HtmlDCRenderer#set_html_text

set_html_text(%(arg-type)String% html, String basepath = ’’, Boolean isdir = true)

Assign text to the renderer. Render then draws
the text onto DC.

#### Parameters

- html HTML text. This is not a filename.
- basepath base directory (html string would be stored there if it was in
  file). It is used to determine path for loading images, for example.
- isdir false if basepath is filename, true if it is directory name
  (see FileSystem for detailed explanation)

### HtmlDCRenderer#render

Integer render(%(arg-type)Integer% x, Integer y, Integer from = 0, Integer dont_render = false)

Renders HTML text to the DC.

#### Parameters

- x,y position of upper-left corner of printing rectangle (see set_size)
- from y-coordinate of the very first visible cell
- dont_render if true then this method only returns y coordinate of the next page
  and does not output anything

Returned value is y coordinate of first cell than didn’t fit onto page.
Use this value as from in next call to Render in order to print multipages
document.

#### Caution!

The Following three methods must always be called before any call to Render (preferably
in this order):

- SetDC
- set_size
- set_html_text

Render() changes the DC’s user scale and does NOT restore it.

### HtmlDCRenderer#get_total_height

Integer get_total_height()

Returns the height of the HTML text. This is important if area height (see set_size)
is smaller that total height and thus the page cannot fit into it. In that case you’re supposed to
call Render as long as its return value is smaller than GetTotalHeight’s.

[This page automatically generated from the Textile source at 2023-06-09 00:45:28 +0000]