#!perl -w
use strict;
use Tk;
use Tk::Dialog;
use PDF::Create;
use PDF::Labels;
my %Address_List;
my $cntr=0;
my $VERSION='0.01';
my $Main=new MainWindow;
my $MenuFrame=$Main->Frame(-relief=>'flat',-borderwidth=>2);
$MenuFrame->grid;
$MenuFrame->Menubutton(-text=>'File',-menuitems=>[['command'=>'Exit',-
+command=>\&Exit]])->pack(-side=>'left');
$MenuFrame->Menubutton(-text=>'Help',-menuitems=>[['command'=>'About',
+-command=>\&About]])->pack(-side=>'right');
my $lblpos=$Main->Label(-text=>'Default Label Position:');
my $pos=$Main->Entry(-width=>2);
$lblpos->grid($pos,-sticky=>'w');
$pos->focus;
my $un=$Main->Label(-text=>'Name:');
my $name=$Main->Entry(-width=>40);
$un->grid($name);
my $Addr=$Main->Label(-text=>'Street:');
my $str=$Main->Entry(-width=>40);
$Addr->grid($str);
my $CSZ=$Main->Label(-text=>'City, State Zip-Code');
my $csz=$Main->Entry(-width=>40);
$CSZ->grid($csz);
my $AddBtn=$Main->Button(-text=>'Add',-command=>sub{Add_List($name,$st
+r,$csz)});
my $CrtBtn=$Main->Button(-text=>'Create PDF',-command=>sub{Create_PDF(
+$pos)});
my $ExtBtn=$Main->Button(-text=>'Exit',-command=>sub{ Exit()});
$AddBtn->grid($CrtBtn,$ExtBtn);
MainLoop;
sub Add_List{
my($Name,$Str,$Csz)=@_;
my $N=$Name->get;
my $S=$Str->get;
my $C=$Csz->get;
$cntr++;
$Address_List{$cntr}=[$N,$S,$C];
&Clear;
}
sub Create_PDF{
my $position=shift;
my $p=$position->get;
if($p eq ""){ $p = 0; }
my $pdf = new PDF::Labels(
$PDF::Labels::PageFormats[0],
filename=>'Labels.pdf',
Author=>'PDF_Label_Maker',
Title=>'Labels'
);
$pdf->setlabel($p);
foreach my $key(keys %Address_List){
$pdf->label("$Address_List{$key}[0]",
"$Address_List{$key}[1]",
"$Address_List{$key}[2]");
}
$pdf->close();
&Done;
}
sub Clear{
$pos->delete(0,'end');
$name->delete(0,'end');
$str->delete(0,'end');
$csz->delete(0,'end');
$pos->focus;
}
sub About{
my $about=$Main->Dialog(-title=>'About PDF Label Maker',-text=>"PDF
+Label Maker Version $VERSION\n Written by Thomas Stanley",-default_b
+utton=>'Ok');
$about->Show;
}
sub Exit{
exit 0;
}
sub Done{
my $Done=$Main->Dialog(-title=>'File Created',-text=>"Labels.pdf was
+ created",-default_button=>'Ok');
$Done->Show;
}
In reply to PDFLM
by TStanley
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.