NAME

Image::CairoSVG - render SVG into a Cairo surface

SYNOPSIS

This example converts an SVG into a PNG:

use Cairo;
use Image::CairoSVG;
my $surface = Cairo::ImageSurface->new ();
my $cairosvg = Image::CairoSVG->new (
    surface => $surface,
);
$cairosvg->render ('file.svg');

DESCRIPTION

METHODS

new

my $cairosvg = Image::CairoSVG->new ();

Use default surface.

my $cairosvg = Image::CairoSVG->new (surface => $surface);

With a surface

Not implemented yet:

my $cairosvg = Image::CairoSVG->new (context => $cr);

render

$cairosvg->render ('some.svg');

Draw an SVG file into a Cairo surface.

line

$cairosvg->line (%attr);

Given SVG input of the form <line >, this renders it onto the Cairo surface.

path

$cairosvg->path (%attr);

rect

$cairosvg->rect (%attr);

Dependencies

Cairo

This is the renderer.

Image::SVG::Path

This is used for parsing the "path" information of the SVG.

XML::Parser

This is used for parsing the SVG itself.

SEE ALSO

CPAN

Other

CairoSVG

http://cairosvg.org/|CairoSVG is a Python SVG renderer in Cairo.

new

my $cairosvg = Image::CairoSVG->new (
    surface => Cairo::ImageSurface->create ('argb32', 100, 100)
);

If a surface is not provided, this creates a Cairo::ImageSurface of dimensions 100 by 100 of rgba format.

render

$self->render ($file);

Render $file onto the Cairo surface of $self.

rect

$cairosvg->rect (%attr);

ellipse

$cairosvg->ellipse (%attr);

circle

$cairosvg->circle (%attr);

polygon

$cairosvg->polygon (%attr);

path

$cairosvg->path (%attr);

Given an SVG path element, send its attribute key / value pairs as %attr to render into the Cairo surface of $cairosvg.

line

$cairosvg->line (%attr);

Render an SVG line onto the surface specified by $cairosvg.

BUGS

This module is a "least effort" attempt to get the parts of SVG which the author needs rendered rendered. It doesn't even pretend to be a full SVG renderer. So if you find the module doesn't do some part of SVG which you want done, please add that to the module and if possible contribute your addition to this module via git.

LICENCE, COPYRIGHT, AUTHOR

Copyright 2014 Ben Bullock bkb@cpan.org. Licence = Perl (Artistic + GNU).

Some parts of the module (specifically the SVG arc drawing code) are translations from the above-mentioned Python program "cairosvg", which is under the "GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007". I'm not really sure how or if this affects the code, but just in case it causes legal issues for someone downstream, I'm mentioning it here.