## Using RSVG with GIO

Using RSVG with GIO

## Synopsis

    enum                RsvgHandleFlags;
    void                rsvg_handle_set_base_gfile          (RsvgHandle *handle,
                                                             GFile *base_file);
    gboolean            rsvg_handle_read_stream_sync        (RsvgHandle *handle,
                                                             GInputStream *stream,
                                                             GCancellable *cancellable,
                                                             GError **error);
    RsvgHandle *        rsvg_handle_new_from_gfile_sync     (GFile *file,
                                                             RsvgHandleFlags flags,
                                                             GCancellable *cancellable,
                                                             GError **error);
    RsvgHandle *        rsvg_handle_new_from_stream_sync    (GInputStream *input_stream,
                                                             GFile *base_file,
                                                             RsvgHandleFlags flags,
                                                             GCancellable *cancellable,
                                                             GError **error);

## Object Hierarchy

      GFlags
       +----RsvgHandleFlags

## Description

## Details

### enum RsvgHandleFlags

    typedef enum {
        RSVG_HANDLE_FLAGS_NONE           = 0,
        RSVG_HANDLE_FLAG_UNLIMITED       = 1 << 0,
        RSVG_HANDLE_FLAG_KEEP_IMAGE_DATA = 1 << 1
    } RsvgHandleFlags;

`RSVG_HANDLE_FLAGS_NONE` | none
`RSVG_HANDLE_FLAG_UNLIMITED` | Allow any SVG XML without size limitations. For security reasons, this should only be used for trusted input! Since: 2.40.3
`RSVG_HANDLE_FLAG_KEEP_IMAGE_DATA` | Keeps the image data when loading images, for use by cairo when painting to e.g. a PDF surface. This will make the resulting PDF file smaller and faster. Since: 2.40.3

### rsvg_handle_set_base_gfile ()

    void                rsvg_handle_set_base_gfile          (RsvgHandle *handle,
                                                             GFile *base_file);

Set the base URI for `handle` from `file`. Note: This function may only be called before `rsvg_handle_write()` or `rsvg_handle_read_stream_sync()` has been called.

`handle` : | a RsvgHandle
`base_file` : | a GFile

Since 2.32

### rsvg_handle_read_stream_sync ()

    gboolean            rsvg_handle_read_stream_sync        (RsvgHandle *handle,
                                                             GInputStream *stream,
                                                             GCancellable *cancellable,
                                                             GError **error);

Reads `stream` and writes the data from it to `handle`.

If `cancellable` is not `NULL`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error `G_IO_ERROR_CANCELLED` will be returned.

`handle` : | a RsvgHandle
`stream` : | a GInputStream
`cancellable` : | a GCancellable, or `NULL`. [allow-none]
`error` : | a location to store a GError, or `NULL`. [allow-none]
Returns : | `TRUE` if reading `stream` succeeded, or `FALSE` otherwise with `error` filled in

Since 2.32

### rsvg_handle_new_from_gfile_sync ()

    RsvgHandle *        rsvg_handle_new_from_gfile_sync     (GFile *file,
                                                             RsvgHandleFlags flags,
                                                             GCancellable *cancellable,
                                                             GError **error);

Creates a new RsvgHandle for `file`.

If `cancellable` is not `NULL`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error `G_IO_ERROR_CANCELLED` will be returned.

`file` : | a GFile
`flags` : | flags from RsvgHandleFlags
`cancellable` : | a GCancellable, or `NULL`. [allow-none]
`error` : | a location to store a GError, or `NULL`. [allow-none]
Returns : | a new RsvgHandle on success, or `NULL` with `error` filled in

Since 2.32

### rsvg_handle_new_from_stream_sync ()

    RsvgHandle *        rsvg_handle_new_from_stream_sync    (GInputStream *input_stream,
                                                             GFile *base_file,
                                                             RsvgHandleFlags flags,
                                                             GCancellable *cancellable,
                                                             GError **error);

Creates a new RsvgHandle for `stream`.

If `cancellable` is not `NULL`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error `G_IO_ERROR_CANCELLED` will be returned.

`input_stream` : | a GInputStream
`base_file` : | a GFile, or `NULL`. [allow-none]
`flags` : | flags from RsvgHandleFlags
`cancellable` : | a GCancellable, or `NULL`. [allow-none]
`error` : | a location to store a GError, or `NULL`. [allow-none]
Returns : | a new RsvgHandle on success, or `NULL` with `error` filled in

Since 2.32