From: Dobrica Pavlinusic Date: Fri, 3 Feb 2012 19:35:18 +0000 (+0100) Subject: use svg template and substitute barcode and call number X-Git-Url: http://git.rot13.org/?p=Printer-Zebra.git;a=commitdiff_plain;h=5cbd12f3fb5fe5f264051495f0eb7adc1b049433 use svg template and substitute barcode and call number --- diff --git a/svg-render.pl b/svg-render.pl index 6624066..e73ae0e 100755 --- a/svg-render.pl +++ b/svg-render.pl @@ -1,16 +1,41 @@ #!/usr/bin/perl use warnings; use strict; +use autodie; # 5166 px = 1000 dpi +my $size = $ENV{SIZE} || '105x40'; + my $w = 832; my $density = $w / 5166 * 1000; warn "# density = $density\n"; -my $from = shift @ARGV || die "usage: $0 template.svg\n"; -system "convert -density $density $from $from.pbm"; +my $barcode = shift @ARGV || die "usage: $0 1301272944 callnumber\n"; + +my $call1 = shift @ARGV; +my $call2 = shift @ARGV; +my $call3 = shift @ARGV; +my $call4 = join(' ', @ARGV); + +my $pbm = "/tmp/$barcode.pbm"; + +open(my $from, '<', "templates/$size.svg"); +open(my $to, '|-', "convert -density $density - $pbm"); +while(<$from>) { + s/1301272944/$barcode/gs && warn "# barcode $barcode\n"; + s/##call1##/$call1/gs && warn "# 1: $call1\n"; + s/##call2##/$call2/gs && warn "# 2: $call2\n"; + s/##call3##/$call3/gs && warn "# 3: $call3\n"; + s/##call4##/$call4/gs && warn "# 4: $call4\n"; + + print $to $_; +} +close($from); +close($to); + +warn "$pbm ", -s $pbm, " bytes\n";