Okay, I've actually USED PDF::Create that others are suggesting and it's okay. In fact, this short program took some existing text and overlaid a grid on top of it to make nice column rules that the data lacked.
#!/usr/bin/perl -w
use strict;
use PDF::Create;
my $font;
my $height=792;
my $width=612;
my $left=20;
my $topmargin=20;
my $pointsize=8;
my $spacing=$pointsize+3;
sub addtext {
my($page, $fh)=@_;
my $l=0;
my $hpos=$height-$topmargin;
while(<$fh>) {
$page->stringl($font, $pointsize, $left, $hpos-=$spacing, $_);
last if ++$l > 66;
}
}
sub boxpage {
my($page)=@_;
$page->line($left, $topmargin,
$left, $height-$topmargin,
);
$page->line( $left, $height-$topmargin,
$width-$left, $height-$topmargin);
$page->line( $width-$left, $height-$topmargin,
$width-$left, $topmargin);
$page->line( $width-$left, $topmargin,
$left, $topmargin);
$page->line($left+42, $topmargin,
$left+42, $height-$topmargin);
$page->line($left+81, $topmargin,
$left+81, $height-$topmargin);
$page->line($left+145, $topmargin,
$left+145, $height-$topmargin);
$page->line($left+183, $topmargin,
$left+183, $height-$topmargin);
}
my $pdf=new PDF::Create('filename' => 'outfile.pdf',
'Version' => '1.2',
'Author' => 'Clinton Pierce',
'Title' => 'Test Report',);
my $root=$pdf->new_page('MediaBox' => [ 0, 0, 612, 792 ]);
$font=$pdf->font('Subtype' => 'Type1',
'Encoding' => 'WinAnsiEncoding',
'BaseFont' => 'Courier');
open(FH, $0) || die;
while(not eof(FH)) {
my $page=$root->new_page();
boxpage($page);
addtext($page, \*FH);
}
$pdf->close;
Now the caveat is, there's not a whole lot PDF::Create can do. No colors. No bitmaps. Not much more than lines, circles and other polygons. No width control on the lines either.
And PDF::Create hasn't been updated in a long, long time and I got a bounce from the e-mail address of the maintainer. But I got enough out of it for my needs...
|