render_element


Description:

[ Version ( since = "2.46" ) ]
public bool render_element (Context cr, string? id, Rectangle element_viewport) throws Error

Renders a single SVG element to a given viewport.

This function can be used to extract individual element subtrees and render them, scaled to a given element_viewport. This is useful for applications which have reusable objects in an SVG and want to render them individually; for example, an SVG full of icons that are meant to be be rendered independently of each other.

Element IDs should look like an URL fragment identifier; for example, pass `foo` (hash `foo`) to get the geometry of the element that has an `id="foo"` attribute.

You can pass `NULL` for the id if you want to render all the elements in the SVG, i.e. to render everything from the root element.

The `element_viewport` gives the position and size at which the named element will be rendered. FIXME: mention proportional scaling.

Parameters:

this

An [class@Rsvg.Handle]

cr

A Cairo context

id

An element's id within the SVG, starting with "#" (a single hash character), for example, `layer1`. This notation corresponds to a URL's fragment ID. Alternatively, pass `NULL` to render the whole SVG document tree.

element_viewport

Viewport size in which to fit the element

Returns:

`TRUE` on success, `FALSE` on error. Errors are returned in the throws argument.

API ordering: This function must be called on a fully-loaded this. See the section "[API ordering]( class.Handle.html#api-ordering)" for details.

Panics: this function will panic if the this is not fully-loaded.