Skip to content
Permalink
Browse files

Added some nice labels for the kits

  • Loading branch information...
dren-dk committed Aug 20, 2011
1 parent b7858cb commit f6d4a726d605e15eeec03e22afab42115115b6e1
Showing with 72 additions and 0 deletions.
  1. BIN labels-zablet.pdf
  2. +72 −0 pdflabels
  3. BIN zablet.png
BIN +56.1 KB labels-zablet.pdf
Binary file not shown.
@@ -0,0 +1,72 @@
#!/usr/bin/perl
use strict;
use warnings;
use PDF::API2;
use GD::Barcode::QRcode;
use FindBin qw($Bin $Script);

my ($type, $start) = ('zablet', '0');
my $bgf = "$Bin/$type.png";
die "Background image not found: $bgf" unless -f $bgf;

sub mm2ps {
my $mm = shift;
return $mm*72/25.4;
}

my $rows = 7;
my $cols = 3;
my $xoff = 8;
my $yoff = 14.5;
my $xsize = 63.5;
my $ysize = 38.1;
my $xpitch = 65.5;
my $ypitch = 38.1;

my $pdf = PDF::API2->new();
my $hb = $pdf->corefont('Helvetica-Bold');
#my $bender = $pdf->ttfont("$Bin/bender/Bender Black.otf");
my $bg = $pdf->image_png($bgf);

my $id = $start;
for my $pn (1..1) {
my $page = $pdf->page();
$page->mediabox('A4');

my $text = $page->text();
my $gfx = $page->gfx;

for my $row (0..$rows-1) {
my $y = $yoff + ($rows-1-$row)*$ypitch;

for my $col (0..$cols-1) {
my $x = $xoff + $col * $xpitch;

my $gfx = $page->gfx;
$gfx->image( $bg, mm2ps($x), mm2ps($y),
mm2ps($xsize), mm2ps($ysize) );

my $url = "HTTP://ZABLET.OSAA.DK";
$id++;
my $qr = $pdf->image_gd(GD::Barcode::QRcode->new(
$url,
{ Ecc => 'Q',
Version=>2,
ModuleSize => 1}
)->plot, -lossless => 1);
$gfx->image($qr, mm2ps($x+3), mm2ps($y+3+2),
mm2ps(30), mm2ps(30));

$gfx->textlabel(mm2ps($x+3+30/2), mm2ps($y+3),
$hb, mm2ps(2), lc($url),
-align => 'center',
);
}
}
}

my $out = "labels-$type.pdf";
$pdf->saveas($out);
system("okular $out");

exit 0;
BIN +46.4 KB zablet.png
Binary file not shown.

0 comments on commit f6d4a72

Please sign in to comment.
You can’t perform that action at this time.