7 die "unsage: $0 card/template.svg 201008159999 login Ime Prezime\n" unless @ARGV;
9 my ($card_svg,$nr,$login,$ime,$prezime) = @ARGV;
11 my $png = $ENV{PNG} || 0;
13 warn "# svg: $card_svg nr: $nr $ime $prezime\n";
16 '200908109999' => $nr,
17 'login0123456789@ffzg.hr' => $login,
18 'Knjižničarko' => $ime,
19 'Čitalić' => $prezime,
22 sub mapping { $mapping->{ $_[0] } }
24 my $re = join('|', keys %$mapping);
26 mkdir 'out' unless -d 'out';
27 my $out = 'out/' . $nr;
29 foreach my $existing ( glob $out . '*' ) {
30 warn "# remove $existing ", -s $existing, " bytes\n";
34 open(my $svg_template, '<', $card_svg);
35 open(my $svg, '>', "$out.svg");
37 while(<$svg_template>) {
41 s{($1)}{mapping($1)}ge;
54 my $actions = "file-open:$out.svg ; export-area-page ; export-id:$part ;";
56 $part =~ s/print-//; # FIXME change svg files
58 system qq{inkscape --actions="$actions ; export-type:pdf ; export-filename:$out.$part.pdf ; export-do ;"};
59 # print $inkscape "$actions ; export-type:png ; export-filename:$out.$part.png ; export-dpi 150 ; export-do ;" if $png;
62 inkscape_export 'print-front';
63 inkscape_export 'print-back';
66 #print $inkscape "$out.svg --export-png $out.png --export-dpi 300\n" if $png;
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 -dPDFFitPage -sDEVICE=pbmraw -sOutputFile=$pbm -f $pdf";
76 system "pdftk $out.front.pdf $out.back.pdf cat output $out.duplex.pdf" if $ENV{DUPLEX};
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";