### Method

# Rsvg Handle render_element

#### Declaration [src]

    gboolean
    rsvg_handle_render_element (
      RsvgHandle* handle,
      cairo_t* cr,
      const char* id,
      const RsvgRectangle* element_viewport,
      GError** error
    )

#### Description [src]

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.

Available since: | 2.46

#### Parameters

`cr` | `cairo_t`
| A Cairo context.
| The data is owned by the caller of the function.
`id` | `const char*`
| 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.
| The argument can be `NULL`.
| The data is owned by the caller of the function.
| The value is a NUL terminated UTF-8 string.
`element_viewport` | `RsvgRectangle`
| Viewport size in which to fit the element.
| The data is owned by the caller of the function.
`error` | `GError **`
| The return location for a `GError*`, or `NULL`.

#### Return value

Returns: | `gboolean`
| `TRUE` on success, `FALSE` on error. Errors are returned in the `error` argument. API ordering: This function must be called on a fully-loaded `handle`. See the section “API ordering” for details. Panics: this function will panic if the `handle` is not fully-loaded.