File: barcode.pl

package info (click to toggle)
libpdf-report-perl 1.36-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 260 kB
  • sloc: perl: 791; makefile: 10
file content (54 lines) | stat: -rw-r--r-- 1,334 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl
use lib qw(../lib);
use PDF::Report;

my $pdf = new PDF::Report(
                          PageSize => "letter",
                          PageOrientation => "portrait",
                          undef => undef
                         );

$pdf->newpage(1);
$pdf->setFont('Helvetica-bold');
$pdf->setSize(16);
my ($width, $height) = $pdf->getPageDimensions();

$pdf->centerString(0, $width, $height-40, "Barcodes");

my $x = $width/3;
my $y = $height-150; 
my @types = qw(3of9 code128 ean13 codabar 2of5int);

my @codes = qw(010203045678909 ABCDEFabcdef012345 010203045678909 
               384318530034967067 384318530034967067);

my @scale = qw(.9 .5 .75 1 .8);

$pdf->setFont('Helvetica');
$pdf->setSize(10);

my $next_line = 120;

foreach my $nbr (0 .. $#types) {
  if ($y < 50) {
   $pdf->newpage(1);
   $y = $height - 80;
  }
  if (($types[$nbr] eq '3of9ext') or ($types[$nbr] eq '3of9extchk')) {
    $ext = 90506;
  } 
  $pdf->centerString(0, $width, $y+85, $types[$nbr]);
  $pdf->drawBarcode($x, $y, $scale[$nbr], 1,
                   $types[$nbr], $codes[$nbr], $ext, 
                   10, 10, 50, 10, ' ', undef, 8, undef);
  $y-=$next_line;
  $ext = "";
}

my $outpdf = $0;
$outpdf =~ s/pl$/pdf/;
open(PDF, "> $outpdf") or die "Error opening $outpdf: $!\n";
print PDF $pdf->Finish();
close(PDF);

exit;