[kansaipm] GD::Barcode 1.15 (QRコード対応版)をリリースしました

Yasushi Nakajima nakajima at netstock.co.jp
Sun Apr 25 21:21:38 CDT 2004


KAWAI,Takanori> 半年ほど前にお騒がせしたQRコード作成モジュールですが、
KAWAI,Takanori> やっとCPANにアップしました。

 ちょっとやってみました。GD::Barcode::QRcodeを使ってPDFJでQRコードを出
すには、こんな感じです。でも、手元にQRコードの読める機械がない…。

use PDFJ;
use GD::Barcode::QRcode;
use strict;

my($text, $ecc, $version, $outfile) = @ARGV;
my $gb = GD::Barcode::QRcode->new($text, {Ecc => $ecc, Version => $version}) 
	or die;
my $bar = barcode_shape($gb->barcode);
my $doc = PDFJ::Doc->new(1.3, 200, 200);
my $page = $doc->new_page;
$bar->show($page, 10, 10);
$doc->print($outfile);

sub barcode_shape {
	my($ptn, $unit) = @_;
	$unit ||= 3;
	my $shape = Shape(SStyle(linewidth => 0.01));
	my $x = 0;
	my @lines = split(/\n/, $ptn);
	my $y = $unit * (@lines - 1);
	for my $line(@lines) {
		for my $ch(split(//, $line)) {
			$shape->box($x, $y, $unit, $unit, ($ch ? 'f' : 'n'));
			$x += $unit;
		}
		$x = 0;
		$y -= $unit;
	}
	$shape;
}


-- 
Yasushi Nakajima <nakajima at netstock.co.jp>




More information about the Kansai-pm mailing list