1 #!/usr/bin/perl
3 # This is a script to render a plain text file into SVG, line by line.
5 use strict;
6 use SVG;
7 use vars qw($VERSION);
8 $VERSION = '1.00';
10 my $svg = new SVG;
12 $svg->comment('Generated by txt2svg');
14 my $i=0;
15 while (<>) {
16 chomp($_);
17 s/\t/ /g; # Convert tabs into spaces, otherwise we get errors about invalid char
19 my $text = $svg->text(id => "text_line_$i",
20 x => 10,
21 y => 12*(1+$i),
22 'xml:space' => 'preserve',
23 style => { 'font' => 'Courier',
24 'font-family' => 'Courier 10 pitch',
25 'font-size' => 10,
26 }
27 )
28 ->cdata($_);
29 $i++;
30 }
32 print $svg->xmlify();