use inkscape --shell to export files
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 14 Aug 2010 12:24:30 +0000 (14:24 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 14 Aug 2010 12:24:30 +0000 (14:24 +0200)
inkscape-render.pl

index df7c73e..3fd33bd 100755 (executable)
@@ -4,6 +4,8 @@ use warnings;
 use strict;
 use autodie;
 
 use strict;
 use autodie;
 
+my $card_svg = 'card/ffzg-2010.svg';
+
 my ($nr,$ime,$prezime) = ( qw/
 200900000042
 Dobrica
 my ($nr,$ime,$prezime) = ( qw/
 200900000042
 Dobrica
@@ -28,7 +30,7 @@ foreach my $existing ( glob $out . '*' ) {
        unlink $existing;
 }
 
        unlink $existing;
 }
 
-open(my $in,     '<', 'template.svg');
+open(my $in,     '<', $card_svg);
 open(my $print,  '>', "$out.print.svg");
 open(my $screen, '>', "$out.screen.svg");
 
 open(my $print,  '>', "$out.print.svg");
 open(my $screen, '>', "$out.screen.svg");
 
@@ -56,6 +58,21 @@ close($in);
 close($print);
 close($screen);
 
 close($print);
 close($screen);
 
+open(my $inkscape, '|-', 'inkscape --shell --without-gui');
+
+sub inkscape_export {
+       my $part = shift;
+       print $inkscape "$out.print.svg --export-area-page --export-pdf $out.$part.pdf --export-id $part\n";
+       print $inkscape "$out.screen.svg --export-png $out.png --export-dpi 300";
+}
+
+inkscape_export 'print-front';
+inkscape_export 'print-back';
+
+close($inkscape);
+
+__END__
+
 #system "inkscape --file $out.print.svg  --export-pdf $out.pdf";
 
 system "inkscape --file $out.print.svg --export-area-page --export-pdf $out.print-front.pdf --export-id print-front";
 #system "inkscape --file $out.print.svg  --export-pdf $out.pdf";
 
 system "inkscape --file $out.print.svg --export-area-page --export-pdf $out.print-front.pdf --export-id print-front";