7 die "unsage: $0 card/template.svg 201008159999 Ime Prezime\n" unless @ARGV;
9 my ($card_svg,$nr,$ime,$prezime) = @ARGV;
11 warn "# svg: $card_svg nr: $nr $ime $prezime\n";
14 '200908109999' => $nr,
15 'Knjižničarko' => $ime,
16 'Čitalić' => $prezime,
19 sub mapping { $mapping->{ $_[0] } }
21 my $re = join('|', keys %$mapping);
23 mkdir 'out' unless -d 'out';
24 my $out = 'out/' . $nr;
26 foreach my $existing ( glob $out . '*' ) {
27 warn "# remove $existing ", -s $existing, " bytes\n";
31 open(my $svg_template, '<', $card_svg);
32 open(my $svg, '>', "$out.svg");
34 while(<$svg_template>) {
38 s{($1)}{mapping($1)}e;
48 open(my $inkscape, '|-', 'inkscape --shell --without-gui');
53 my $shell = "$out.svg --export-area-page --export-id $part";
55 $part =~ s/print-//; # FIXME change svg files
57 print $inkscape "$shell --export-pdf $out.$part.pdf\n";
58 print $inkscape "$shell --export-png $out.$part.png --export-dpi 150\n";
61 inkscape_export 'print-front';
62 inkscape_export 'print-back';
65 print $inkscape "$out.svg --export-png $out.png --export-dpi 300\n";
69 foreach my $pdf ( glob "$out*.pdf" ) {
72 warn "# rendering $pdf => $pbm using ghostscript\n";
73 system "gs -dNOPAUSE -dBATCH -q -r300x300 -dDEVICEWIDTHPOINTS=243 -dDEVICEHEIGHTPOINTS=155 -sDEVICE=pbmraw -sOutputFile=$pbm -f $pdf";
76 system "pdftk $out.front.pdf $out.back.pdf cat output $out.duplex.pdf";
80 #system "inkscape --file $out.print.svg --export-pdf $out.pdf";
82 system "inkscape --file $out.print.svg --export-area-page --export-pdf $out.print-front.pdf --export-id print-front";
83 system "inkscape --file $out.print.svg --export-area-page --export-pdf $out.print-back.pdf --export-id print-back";
84 system "pdftk $out.print-front.pdf $out.print-back.pdf cat output $out.print-duplex.pdf";
86 #system "inkscape --file $out.screen.svg --export-png $out.png --export-dpi 180";
88 #system "inkscape --file $out.screen.svg --export-png $out.300.png --export-dpi 300";
90 system "inkscape --file $out.print.svg --export-area-page --export-png $out.print-front.png --export-dpi 150 --export-id print-front --export-id-only";
91 system "inkscape --file $out.print.svg --export-area-page --export-png $out.print-back.png --export-dpi 150 --export-id print-back --export-id-only";
94 #system "qiv $out.png";
95 #system "xpdf $out.pdf";