Home > Uncategorized > Barcodes and Perl

Barcodes and Perl

Digging around for a way to generate BarCodes without paying the hundreds of dollars most commerical apps want, I stumbled across this by accident:

http://deadnode.org/sw/barpass/

Which lead to this:

#!/usr/bin/perl -w
# Hacked by Nick Peelman
# Apr 17 2008
#
#
# Based on  BarPass, used for generating passwords with corresponding barcodes, kudos to James!
# http://deadnode.org/sw/barpass/

use strict;
use String::Random;
use PDF::Reuse;
use PDF::Reuse::Barcode;

my ($x,$y,$count,$i) = (-100,50,0,0);
my $rp = new String::Random;
prFile('barpass.pdf');
for $i (1 .. 2000) { pass( $i ); }
prEnd();
exit;
sub pass
  {
 my $a;
 ($a) = @_;
while (length($a) < 4) {
 	$a = "0$a";
 }
$x += 125;
    if ($x>=500)
      {
 $y+=35;
 $x=50;
      }

 if ($y>750)

 {
 	prPage();
 	$y=50;
 }
    $count++;
    PDF::Reuse::Barcode::Code128(x => $x,
 			 y => $y,
 			 mode => 'graphic',
 			 value => "A00$a");
  }

It can quite literally spit out a PDF with 2000 sequential bar codes evenly spaced in about 2 seconds. I’m ecstatic as hell about this inventory stuff, I still have to get my Scanner/AJAX Web Page integration going, I haven’t got the first line of code started but I DO have a decent SVN repository setup now, as soon as i get the database replicated I can dev it from home and we’re off to the races! w00t!

Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.
blog comments powered by Disqus