View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Christophe Mertz > svg2zinc-perl_0.9 > SVG::SVG2zinc



Annotate this POD

View/Report Bugs
Module Version: 0.09   Source  


SVG::SVG2zinc - a module to display or convert svg files in scripts, classes, images...


 use SVG::SVG2zinc;

 &SVG::SVG2zinc::parsefile('file.svg', 'Backend','file.svg',
                           -out => 'outfile',
                           -verbose => $verbose,
                           -namespace => 0|1,
                           -prefix => 'string', 

 # to generate a Perl script: 
                           -out => '');

 # to generate a Perl Class:
                           -out => '');

 # to display a svgfile:
 &SVG::SVG2zinc::parsefile('file.svg', 'Display'); 

 #To convert a svgfile in png/jpeg file:
 &SVG::SVG2zinc::parsefile('file.svg', 'Image', 
                           -out => 'file.jpg');

 # to generate a Tcl script: 
                           -out => 'file.tcl');


Depending on the used Backend, &SVG::SVG2zinc::parsefile either generates a Perl Class, Perl script, Tcl Script, bitmap images or displays SVG files inside a Tk::Zinc widget.

SVG::SVG2zinc could be extended to generate Python scripts and/or classes, or other files, just by sub-classing SVG::SVG2zinc::Backend(3pm)

==head1 HOW IT WORKS

This converter creates some TkZinc items associated to most SVG tags. For example, <SVG> or <G> tags are transformed in TkZinc groups. <PATH> are converted in TkZinc curves.... many more to come...

==head2 TkZinc items tags

Every TkZinc item created by the parser get one or more tags. If the corresponding svg tag has an Id, this Id will be used as a tag, after some cleaning due to TkZinc limitation on tag values (no dot, star, etc...). If the corresponding svg tag has no Id, the parser add a tag of the following form : __<itemtype>__<integer>. If the parser is provided a -prefix option, the prefix is prepended to the tag: <prefix>__<itemtype>__<integer>

The TkZinc group associated to the top <SVG> tag has the following tag 'svg_top', as well as 'width=integer' 'heigth=integer' tags if width and height are defined in the top <SVG> tag. These tags can be used to find the group and to get its desired width and height.

==head2 RunTime code

There is currently on new Tk::Zinc method needed when executing perl code generated. This perl Tk::Zinc::adaptViewport function should be translated and included or imported in any script generated in an other scripting language (eg. Tcl or Python).


Some limitations are due to differences between Tk::Zinc and SVG graphic models :

Drawing width

Drawing width are zoomed in SVG but are not in Tk::Zinc where it is constant whatever the zoom factor is.

Gradient Transformation

Gradient Transformation is not possible in Tk::Zinc. May be it could be implemented by the converter?

Rounded Rectangles

Rectangles cannot have rounded corners in Tk::Zinc. Could be implemented, by producing curve item rather than rectangles in Tk::zinc. Should be implemented in a future release of Tk::Zinc

Skew and Matrix transforms

Skew and Matrix transforms are not yet available in Tk::Zinc 3.295. Hopefully they should be available in a future release.

Text and tspan tags

Text and tspan tags are very complex items in SVG, for example placement can be very precise and complex. Many such features are difficult to implement in Tk::Zinc and are not currently implemented


Font management is still limited. It will be rotatable and zoomable in future release of Tk::Zinc. SVG fonts included in a document are not readed, currently.

SVG image filtering

No image filtering functions are (and will be) available with Tk::Zinc, except if YOU want to contribute?

ClipPath tag

The SVG ClipPath tag is a bit more powerfull than Tk::Zinc clipping (clipper is limited to one item). So currently this is not implemented at all in SVG::SVG2zinc

There are also some limitations due to the early stage of the converter:


CSS in external url is not yet implemented

SVG animation and scripting

No animation is currently available, neither scripting in the SVG file. But Perl or Tcl are scripting languages,

switch tag

The SVG switch tag is only partly implemented, but should work in most situations

href for images

href for images can only reference a file in the same directory than the SVG source file.

It was said there is still one hidden bug... but please patch and/or report it to the author! Any (simple ?)

SVG file not correctly rendered by this module (except for limitations listed previously) could be send to the author with little comments about the expected rendering and observed differences.

SEE ALSO ^ a sample script using and demonstrating SVG::SVG2zinc

SVG::SVG2zinc::Backend(3pm) to defined new backends.

Tk::Zinc(3) TkZinc is available at


Christophe Mertz <>

many patches and extensions from Alexandre Lemort <>

helps from Celine Schlienger <> and Stéphane Chatty <>


CENA (C) 2002-2003

This program is free software; you can redistribute it and/or modify it under the term of the LGPL licence.

syntax highlighting: