Rsvg.Handle.get_geometry_for_layer

### Method

# Rsvg Handleget_geometry_for_layer

since: 2.46

#### Declaration [src]

    gboolean
    rsvg_handle_get_geometry_for_layer (
      RsvgHandle* handle,
      const char* id,
      const RsvgRectangle* viewport,
      RsvgRectangle* out_ink_rect,
      RsvgRectangle* out_logical_rect,
      GError** error
    )

#### Description [src]

Computes the ink rectangle and logical rectangle of an SVG element, or the whole SVG, as if the whole SVG were rendered to a specific viewport.

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.

The “ink rectangle” is the bounding box that would be painted for fully-stroked and filled elements.

The “logical rectangle” just takes into account the unstroked paths and text outlines.

Note that these bounds are not minimum bounds; for example, clipping paths are not taken into account.

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

This operation is not constant-time, as it involves going through all the child elements.

Available since: 2.46

#### Parameters

`id`

  Type: `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 compute the geometry for the whole SVG.

  The argument can be `NULL`.
  The data is owned by the caller of the method.
  The value is a NUL terminated UTF-8 string.

`viewport`

  Type: `RsvgRectangle`

  Viewport size at which the whole SVG would be fitted.

  The data is owned by the caller of the method.

`out_ink_rect`

  Type: `RsvgRectangle`

  Place to store the ink rectangle of the element.

  The argument will be set by the function.
  The argument can be `NULL`.
  The returned data is owned by the instance.

`out_logical_rect`

  Type: `RsvgRectangle`

  Place to store the logical rectangle of the element.

  The argument will be set by the function.
  The argument can be `NULL`.
  The returned data is owned by the instance.

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will be left initialized to `NULL` by the method if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `gboolean`

`TRUE` if the geometry could be obtained, or `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.