#!/usr/bin/perl ################################################################### # #Copyright (c) 2007, Harald Schioeberg # #All rights reserved # #Redistribution and use in source and binary forms, with or without #modification, are permitted provided that the following conditions #are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # #THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS #"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR #A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR #CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, #EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, #PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR #PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF #LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING #NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS #SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # #################################################################### use strict; use File::Temp qw/tempfile/; #### # Configuration #### my $SCALE=472; # 1200 = units are inch # 472 = units are centimeters # Borders of the sheet my $MARGIN_TOP = 0; my $MARGIN_LEFT= 0.8; # Offset between two labels my $XOFFSET = 10; my $YOFFSET = 4.1; # Layout of the sheet my $COLS = 2; my $ROWS = 7; # Binarys needed my $FIG2DEV = "/usr/bin/fig2dev -L ps"; #### # End of configuration #### sub usage { print STDERR <&STDOUT"; printcode_header($fighandle); for (my $col = 0; $col < $COLS; $col++) { for (my $row = 0; $row < $ROWS; $row++) { my $tag = shift @tags; next unless $tag; my $epsfile = genps($tag); push @psfiles, $epsfile; $x = int(($MARGIN_LEFT + $col * $XOFFSET) * $SCALE); $y = int(($MARGIN_TOP + $row * $YOFFSET) * $SCALE); printcode($fighandle, $tag, $epsfile, $x, $y); }} close $fighandle; foreach my $file (@psfiles) { system("rm $file"); } } sub genps { my $tag = shift; my ($fh, $filename) = tempfile(DIR => "/tmp", SUFFIX => ".eps"); open SAVEDOUT, ">&STDOUT"; open STDOUT, ">&=", $fh->fileno or die "cant redirect\n"; system ("barcode -E -b $tag -e 39 -c -n"); close STDOUT; open STDOUT, ">&SAVEDOUT"; return $filename; } sub movecords { my $cords = shift; my $x = shift; my $y = shift; chomp $cords; my @cords = split / /, $cords; for (my $i; $i<= $#cords-1; $i+=2) { $cords[$i] += $x; $cords[$i+1] += $y; } return join " ", @cords; } sub printcode_header { my $file = shift; print $file <