File:  [LON-CAPA] / doc / build / Attic / barcode.html
Revision 1.2: download - view: text, annotated - select for diffs
Mon Apr 23 13:11:41 2001 UTC (23 years ago) by harris41
Branches: MAIN
CVS tags: version_1_0_3, version_1_0_2, version_1_0_1, version_1_0_0, version_0_99_5, version_0_99_4, version_0_99_3, version_0_99_2, version_0_99_1, version_0_99_0, version_0_6_2, version_0_6, version_0_5_1, version_0_5, version_0_4, stable_2002_spring, stable_2002_july, stable_2002_april, stable_2001_fall, conference_2003, STABLE, HEAD
including sample code (written by authors of GD-Barcode.pm) -Scott

<pre>
* determing source build procedure for
  LON-CAPA-barcode-3.1-1.i386.rpm
  Components:
  + gd library
  + GD perl module
  + GD Barcode perl module

Looking
at things for a bit, I've decided to go with the newer,
more powerful GD-Barcode perl module as opposed to 
the Barcode-Code128 perl module.

These are the installation instructions and sample
png images in case you are interested. These instructions
work for the RedHat-6.2/LON-CAPA development distribution.

wget http://www.boutell.com/gd/http/gd-1.8.4.tar.gz
tar xzvf gd-1.8.4.tar.gz
wget http://www.cpan.org/modules/by-module/GD/GD-1.33.tar.gz
tar xzvf GD-1.33.tar.gz
cd GD-1.33
cp patch_gd.pl ../gd-1.8.4
cd ../gd-1.8.4
perl patch_gd.pl
./configure
make
make check
(as root)
make install
cd ../GD-1.33
perl Makefile.PL
Build JPEG support? [y] n
Build FreeType support? [y] n
Build XPM support? [y] n
make
make test
(as root)
make install
wget http://www.cpan.org/modules/by-module/GD/GD-Barcode-1.13.tar.gz
tar xzvf GD-Barcode-1.13.tar.gz
cd GD-Barcode-1.13
perl Makefile.PL
make
make test
(as root)
make install

I am going to now calculate the installed files, ownerships, and
permissions, and make part of the LON-CAPA installation
(LON-CAPA-barcode-3.1-1.i386.rpm).

-Scott
</pre>

Example usage code #1 (from the GD-Barcode samples directory)
<pre>
use strict;
use GD::Barcode;

my $oGdBar;
#1)EAN13
#1.1 NORMAL
print "=======================\nEAN13: NORMAL\n";
$oGdBar = GD::Barcode->new('EAN13', '123456789012');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>EAN13.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#1.2 Error
print "EAN13: ERROR\n";
$oGdBar = GD::Barcode->new('EAN13', '12345678901');
print "ERROR:", $GD::Barcode::errStr, "\n";
undef $oGdBar;

#2)EAN8
#2.1 NORMAL
print "=======================\nEAN8: NORMAL\n";
$oGdBar = GD::Barcode->new('EAN8', '1234567');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>EAN8.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#2.2 Error
print "EAN8: ERROR\n";
$oGdBar = GD::Barcode->new('EAN8', 'A1234567');
print "ERROR:", $GD::Barcode::errStr, "\n";
undef $oGdBar;

#3)UPC-A
#3.1 NORMAL
print "=======================\nUPCA: NORMAL\n";
$oGdBar = GD::Barcode->new('UPCA', '12345678901');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>UPCA.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#3.2 Error
print "UPCA: ERROR\n";
$oGdBar = GD::Barcode->new('UPCA','12345678901132');
print "ERROR:", $GD::Barcode::errStr, "\n";
undef $oGdBar;

#4)UPC-E
#4.1 NORMAL
print "=======================\nUPCE: NORMAL\n";
$oGdBar = GD::Barcode->new('UPCE', '1234567');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>UPCE.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#4.2 Error
print "UPCE: ERROR\n";
$oGdBar = GD::Barcode->new('UPCE', '123456788');
print "ERROR:", $GD::Barcode::errStr, "\n";
undef $oGdBar;

#5)NW7
#5.1 NORMAL
print "=======================\nNW7: NORMAL\n";
$oGdBar = GD::Barcode->new('NW7', '12345678');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>NW7.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#5.2 Error
print "NW7: ERROR\n";
$oGdBar = GD::Barcode->new('NW7', 'NW7ERROR');
print "ERROR:", $GD::Barcode::errStr, "\n";
undef $oGdBar;

#6)CODE-39
#6.1 NORMAL
print "=======================\nCode39: NORMAL\n";
$oGdBar = GD::Barcode->new('Code39', '*123456789012*');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>Code39.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#6.2 Error
print "Code39: ERROR\n";
$oGdBar = GD::Barcode->new('Code39', '*12345678901;*');
print "ERROR:", $GD::Barcode::errStr, "\n";
undef $oGdBar;

#7)ITF(Interleaved 2 of 5)
#7.1 NORMAL
print "=======================\nITF: NORMAL\n";
$oGdBar = GD::Barcode->new('ITF', '0123456789');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>ITF.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#7.2 Error
print "ITF: ERROR\n";
$oGdBar = GD::Barcode->new('ITF', '123456788A');
print "ERROR:", $GD::Barcode::errStr, "\n";
undef $oGdBar;

#8)Industrial2of5
#8.1 NORMAL
print "=======================\nIndustrial2of5: NORMAL\n";
$oGdBar = GD::Barcode->new('Industrial2of5', '0123456789');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>Industrial2of5.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#8.2 Error
print "Industrial2of5: ERROR\n";
$oGdBar = GD::Barcode->new('Industrial2of5', '123456788A');
print "ERROR:", $GD::Barcode::errStr, "\n";
undef $oGdBar;

#9)IATA2of5
#9.1 NORMAL
print "=======================\nIATA2of5: NORMAL\n";
$oGdBar = GD::Barcode->new('IATA2of5', '0123456789');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>IATA2of5.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#9.2 Error
print "IATA2of5: ERROR\n";
$oGdBar = GD::Barcode->new('IATA2of5', '123456788A');
print "ERROR:", $GD::Barcode::errStr, "\n";
undef $oGdBar;

#10)Matrix2of5
#10.1 NORMAL
print "=======================\nMatrix2of5: NORMAL\n";
$oGdBar = GD::Barcode->new('Matrix2of5', '0123456789');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>Matrix2of5.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#10.2 Error
print "Matrix2of5: ERROR\n";
$oGdBar = GD::Barcode->new('Matrix2of5', '123456788A');
print "ERROR:", $GD::Barcode::errStr, "\n";
undef $oGdBar;

#11)COOP2of5
#11.1 NORMAL
print "=======================\nCOOP2of5: NORMAL\n";
$oGdBar = GD::Barcode->new('COOP2of5', '0123456789');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>COOP2of5.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#11.2 Error
print "COOP2of5: ERROR\n";
$oGdBar = GD::Barcode->new('COOP2of5', '123456788A');
print "ERROR:", $GD::Barcode::errStr, "\n";
undef $oGdBar;
</pre>

Example usage code #2 (from the GD-Barcode samples directory)
<pre>
use strict;
use GD::Barcode::EAN8;
use GD::Barcode::EAN13;
use GD::Barcode::UPCA;
use GD::Barcode::UPCE;
use GD::Barcode::NW7;
use GD::Barcode::Code39;
use GD::Barcode::ITF;
use GD::Barcode::Industrial2of5;
use GD::Barcode::Matrix2of5;
use GD::Barcode::IATA2of5;
use GD::Barcode::COOP2of5;

my $oGdBar;
#1)EAN13
#1.1 NORMAL
print "=======================\nEAN13: NORMAL\n";
$oGdBar = GD::Barcode::EAN13->new('123456789012');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>EAN13.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#1.2 Error
print "EAN13: ERROR\n";
$oGdBar = GD::Barcode::EAN13->new('12345678901');
print "ERROR:", $GD::Barcode::EAN13::errStr, "\n";
undef $oGdBar;

#2)EAN8
#2.1 NORMAL
print "=======================\nEAN8: NORMAL\n";
$oGdBar = GD::Barcode::EAN8->new('1234567');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>EAN8.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#2.2 Error
print "EAN8: ERROR\n";
$oGdBar = GD::Barcode::EAN8->new('A1234567');
print "ERROR:", $GD::Barcode::EAN8::errStr, "\n";
undef $oGdBar;

#3)UPC-A
#3.1 NORMAL
print "=======================\nUPCA: NORMAL\n";
$oGdBar = GD::Barcode::UPCA->new('12345678901');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>UPCA.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#3.2 Error
print "UPCA: ERROR\n";
$oGdBar = GD::Barcode::UPCA->new('12345678901132');
print "ERROR:", $GD::Barcode::UPCA::errStr, "\n";
undef $oGdBar;

#4)UPC-E
#4.1 NORMAL
print "=======================\nUPCE: NORMAL\n";
$oGdBar = GD::Barcode::UPCE->new('1234567');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>UPCE.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#4.2 Error
print "UPCE: ERROR\n";
$oGdBar = GD::Barcode::UPCE->new('123456788');
print "ERROR:", $GD::Barcode::UPCE::errStr, "\n";
undef $oGdBar;

#5)NW7
#5.1 NORMAL
print "=======================\nNW7: NORMAL\n";
$oGdBar = GD::Barcode::NW7->new('12345678');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>NW7.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#5.2 Error
print "NW7: ERROR\n";
$oGdBar = GD::Barcode::NW7->new('NW7ERROR');
print "ERROR:", $GD::Barcode::NW7::errStr, "\n";
undef $oGdBar;

#6)CODE-39
#6.1 NORMAL
print "=======================\nCode39: NORMAL\n";
$oGdBar = GD::Barcode::Code39->new('*123456789012*');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>Code39.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#6.2 Error
print "Code39: ERROR\n";
$oGdBar = GD::Barcode::Code39->new('*12345678901;*');
print "ERROR:", $GD::Barcode::Code39::errStr, "\n";
undef $oGdBar;

#7)ITF
#7.1 NORMAL
print "=======================\nITF: NORMAL\n";
$oGdBar = GD::Barcode::Code39->new('1234567890*');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>ITF.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#7.2 Error
print "ITF: ERROR\n";
$oGdBar = GD::Barcode::ITF->new('*1234567');
print "ERROR:", $GD::Barcode::ITF::errStr, "\n";
undef $oGdBar;

#8. Industrial2of5
#8.1 NORMAL
print "=======================\nIndustrial2of5: NORMAL\n";
$oGdBar = GD::Barcode::Industrial2of5->new('0123456789');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>Industrial2of5.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#8.2 Error
print "Industrial2of5: ERROR\n";
$oGdBar = GD::Barcode::Industrial2of5->new('A12345678901');
print "ERROR:", $GD::Barcode::Industrial2of5::errStr, "\n";
undef $oGdBar;

#9. IATA2of5
#9.1 NORMAL
print "=======================\nIATA2of5: NORMAL\n";
$oGdBar = GD::Barcode::IATA2of5->new('0123456789');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>IATA2of5.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#10.2 Error
print "IATA2of5: ERROR\n";
$oGdBar = GD::Barcode::IATA2of5->new('A12345678901');
print "ERROR:", $GD::Barcode::IATA2of5::errStr, "\n";
undef $oGdBar;

#10. Matrix2of5
#10.1 NORMAL
print "=======================\nMatrix2of5: NORMAL\n";
$oGdBar = GD::Barcode::Matrix2of5->new('0123456789');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>Matrix2of5.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#10.2 Error
print "Matrix2of5: ERROR\n";
$oGdBar = GD::Barcode::Matrix2of5->new('A12345678901');
print "ERROR:", $GD::Barcode::Matrix2of5::errStr, "\n";
undef $oGdBar;

#11. COOP2of5
#11.1 NORMAL
print "=======================\nCOOP2of5: NORMAL\n";
$oGdBar = GD::Barcode::COOP2of5->new('0123456789');
print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
open(OUT, '>COOP2of5.png');
binmode OUT;					#for Windows
print OUT $oGdBar->plot->png;
close OUT;
undef $oGdBar;

#11.2 Error
print "COOP2of5: ERROR\n";
$oGdBar = GD::Barcode::COOP2of5->new('A12345678901');
print "ERROR:", $GD::Barcode::COOP2of5::errStr, "\n";
undef $oGdBar;
</pre>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>