PDF-Builder

 view release on metacpan or  search on metacpan

examples/BarCode.pl  view on Meta::CPAN

delete $barcode->{'Filter'};

$grfx->formimage($barcode, centerbc($barcode, @cellSize, @base), $scale);

# caption
drawCaption([$type], 'LC');

$grfx->restore();

# ----------------------------------------------------
# 4. Code 128C
# alphabet: 0..9
# length: max 10?, 2n values in this mode
# START CODE C, may change to CODE x midstream 
# 4 distinct bar and gap widths
@cellLoc = makeCellLoc(0);
@cellSize = (170, 131); 
$grfx->save();

makeCell(@cellLoc, @cellSize);
@base=@cellLoc;
#$base[0] += 10;
#$base[1] += 10;
$text->font($fontR, 20);
$text->strokecolor('black');
$text->fillcolor('black');
$text->leading(15);

$type = 'Code 128 C';
#$content = '0123456789';  # doesn't work!
$content = 'Test Of '.$type;
$barcode = $pdf->xo_code128(
    'code' => $content,
    'zone' => $bar_height,
    'umzn' => 0,
    'lmzn' => 10,
    'font' => $fontH,
    'fnsz' => 10,
    'mils' => $mils,
);
$barcode->{'-docompress'} = 0;
delete $barcode->{'Filter'};

$grfx->formimage($barcode, centerbc($barcode, @cellSize, @base), $scale);

# caption
drawCaption([$type], 'LC');

$grfx->restore();

# ----------------------------------------------------
# 5. Code EAN-128
# note that EAN-128 is part of Code 128
# alphabet:   128 ASCII characters 0x00..0x7F or 99 digit pairs
#  CODE A:  ASCII sp.._ (x20..x5F) NUL..US (x00..x1F)
#  CODE B:  ASCII sp..DEL (x20..x7F) with | (x7C) replaced by a hook symbol
#  CODE C:  numeric decimal 00..99
#    all alphabets have additional EAN-128-specific controls in alphabet
# superset of CODE 128, with FNC1 required after START CODE x
# length: there appears to be a lengh limit of around 8 digits per (group), and
#      codes will overlay each other if too long. if groups short enough,
#      length is unlimited
@cellLoc = makeCellLoc(0);
@cellSize = (170, 131); 
$grfx->save();

makeCell(@cellLoc, @cellSize);
@base=@cellLoc;
#$base[0] += 10;
#$base[1] += 10;
$text->font($fontR, 20);
$text->strokecolor('black');
$text->fillcolor('black');
$text->leading(15);

$type = 'Code EAN-128';
#$content = '00123456780000000001';  # seems to be too long
$content = '(00)12345(11)0001';
$barcode = $pdf->xo_code128(
    'code' => $content,
    'zone' => $bar_height,
    'umzn' => 0,
    'lmzn' => 10,
    'font' => $fontH,
    'fnsz' => 10,
    'mils' => $mils,
);
$barcode->{'-docompress'} = 0;
delete $barcode->{'Filter'};

$grfx->formimage($barcode, centerbc($barcode, @cellSize, @base), $scale);

# caption
drawCaption([$type], 'LC');

$grfx->restore();

# ----------------------------------------------------
# 6. Code 3 of 9 (aka Code39)
# alphabet: 0..9 A..Z _ sp - $ / . + %
# length: up to 43
# narrow bar/gap and wide bar/gap (3 to 5.3 times wider) 1 character is 9 bars
#   and spaces, with 3 wide and 6 narrow
# * used for start and stop characters
@cellLoc = makeCellLoc(0);
@cellSize = (170, 131); 
$grfx->save();

makeCell(@cellLoc, @cellSize);
@base=@cellLoc;
#$base[0] += 10;
#$base[1] += 10;
$text->font($fontR, 20);
$text->strokecolor('black');
$text->fillcolor('black');
$text->leading(15);

$type = 'Code 3 of 9';
##$content = 'Test '.$type;  # 3 of 9 will uppercase this
$content = 'ABC 123';  # does NOT match scandit example!
$barcode = $pdf->xo_3of9(



( run in 2.816 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )