## Using RSVG with GIO

Using RSVG with GIO

## Functions

void | rsvg_handle_set_base_gfile ()
gboolean | rsvg_handle_read_stream_sync ()
RsvgHandle * | rsvg_handle_new_from_gfile_sync ()
RsvgHandle * | rsvg_handle_new_from_stream_sync ()

## Types and Values

enum | RsvgHandleFlags

## Description

## Functions

### 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()` have been called.

#### Parameters

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` .

Before calling this function, you may need to call `rsvg_handle_set_base_uri()` or `rsvg_handle_set_base_gfile()` to set the "base file" for resolving references to external resources. SVG elements like `<image>` which reference external resources will be resolved relative to the location you specify with those functions.

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.

#### Parameters

handle | a RsvgHandle |
stream | a GInputStream |
cancellable | a GCancellable, or `NULL`. | [nullable]
error | a location to store a GError, or `NULL`. | [optional]

#### 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` .

This function sets the "base file" of the handle to be `file` itself, so SVG elements like `<image>` which reference external resources will be resolved relative to the location of `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 in `error` .

#### Parameters

file | a GFile |
flags | flags from RsvgHandleFlags |
cancellable | a GCancellable, or `NULL`. | [nullable]
error | a location to store a GError, or `NULL`. | [optional]

#### 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` .

This function sets the "base file" of the handle to be `base_file` if provided. SVG elements like `<image>` which reference external resources will be resolved relative to the location of `base_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 in `error` .

#### Parameters

input_stream | a GInputStream |
base_file | a GFile, or `NULL`. | [nullable]
flags | flags from RsvgHandleFlags |
cancellable | a GCancellable, or `NULL`. | [nullable]
error | a location to store a GError, or `NULL`. | [optional]

#### Returns

a new RsvgHandle on success, or `NULL` with `error` filled in

Since: 2.32

## Types and Values

### enum RsvgHandleFlags

#### Members

RSVG_HANDLE_FLAGS_NONE | No flags are set. |
RSVG_HANDLE_FLAG_UNLIMITED | Disable safety limits in the XML parser. Libxml2 has several limits designed to keep malicious XML content from consuming too much memory while parsing. For security reasons, this should only be used for trusted input! Since: 2.40.3 |

RSVG_HANDLE_FLAG_KEEP_IMAGE_DATA

Use this if the Cairo surface to which you are rendering is a PDF, PostScript, SVG, or Win32 Printing surface. This will make librsvg and Cairo use the original, compressed data for images in the final output, instead of passing uncompressed images. This will make a Keeps the image data when loading images, for use by cairo when painting to e.g. a PDF surface. For example, this will make the a resulting PDF file smaller and faster. Please see the Cairo documentation for details. Since: 2.40.3