SVG Surfaces

SVG Surfaces — Rendering SVG documents

Synopsis




cairo_surface_t* cairo_svg_surface_create   (const char *filename,
                                             double width_in_points,
                                             double height_in_points);
cairo_surface_t* cairo_svg_surface_create_for_stream
                                            (cairo_write_func_t write_func,
                                             void *closure,
                                             double width_in_points,
                                             double height_in_points);
void        cairo_svg_surface_set_dpi       (cairo_surface_t *surface,
                                             double x_dpi,
                                             double y_dpi);

Description

Details

cairo_svg_surface_create ()

cairo_surface_t* cairo_svg_surface_create   (const char *filename,
                                             double width_in_points,
                                             double height_in_points);

Creates a SVG surface of the specified size in points to be written to filename.

filename : a filename for the SVG output (must be writable)
width_in_points : width of the surface, in points (1 point == 1/72.0 inch)
height_in_points : height of the surface, in points (1 point == 1/72.0 inch)
Returns : a pointer to the newly created surface. The caller owns the surface and should call cairo_surface_destroy when done with it. This function always returns a valid pointer, but it will return a pointer to a "nil" surface if an error such as out of memory occurs. You can use cairo_surface_status() to check for this.

cairo_svg_surface_create_for_stream ()

cairo_surface_t* cairo_svg_surface_create_for_stream
                                            (cairo_write_func_t write_func,
                                             void *closure,
                                             double width_in_points,
                                             double height_in_points);

Creates a SVG surface of the specified size in points to be written incrementally to the stream represented by write and closure.

write_func :
closure : the closure argument for write
width_in_points : width of the surface, in points (1 point == 1/72.0 inch)
height_in_points : height of the surface, in points (1 point == 1/72.0 inch)
Returns : a pointer to the newly created surface. The caller owns the surface and should call cairo_surface_destroy when done with it. This function always returns a valid pointer, but it will return a pointer to a "nil" surface if an error such as out of memory occurs. You can use cairo_surface_status() to check for this.

cairo_svg_surface_set_dpi ()

void        cairo_svg_surface_set_dpi       (cairo_surface_t *surface,
                                             double x_dpi,
                                             double y_dpi);

Set the horizontal and vertical resolution for image fallbacks. When the svg backend needs to fall back to image overlays, it will use this resolution. These DPI values are not used for any other purpose, (in particular, they do not have any bearing on the size passed to cairo_svg_surface_create() nor on the CTM).

surface : a svg cairo_surface_t
x_dpi : horizontal dpi
y_dpi : vertical dpi