First time using Perl & PDF::API2



Hi!,

Not sure if using PDF::API2 is a good choice or not. Little to no
doc.

In the following code I am able to create the first page ok. Not sure
I am creating the next page correctly or not, but it exist when I open
the PDF file. In the "sub paging " I create the next page, but the
script does not print in the next page. Do I have to tell it to print
on page 2? If so how?

How do I add an image, jpg etc.

Thanks,

Jerry

#!/c:\\Perl\\bin\\perl

use strict;
..
..
..
sub paging {

if( $y <= 50 ) {
$col = ( $col == 0 ) ? $colWidth : 0;
$x = 72 + $col;
$y = $ymax - 20;
$page = $pdf->page(++$page) if $col == $colWidth;
# $gfx = $page->gfx ;
$page = $pdf->openpage($page);
}
}

sub sub_header {
my $name = shift;
my $item = shift;
my $product = shift;
my $header = shift;
my $standard = shift;

print "$name*$product*\n";
$ref{ $name }{ type }[0] =~ s/20\'\/40\'/20\' 40\'/;
print FO "\n$ref{ $name }{ type }[0]$standard\n\n$header\n";
$ref{ $item }{ headersub }[ 0 ]++;
$line += 5;
paging;
$fnt = $pdf->corefont('Arial-BoldItalic',-encoding => 'latin1');
$gfx->textlabel( $x, $y -= 20, $fnt, $Mfnt, "$ref{ $name }{ type }
[0]$standard", -color=>[0.2]);
$fnt = $pdf->corefont('Arial-Bold',-encoding => 'latin1');
$gfx->textlabel( $x, $y -= 20, $fnt, $Mfnt, $header, -
color=>[0.2]);
$x = 72 + $col;
}

sub product {
my $cnt = shift;
my $c = shift;
my $product = shift;
my $name = shift;
my $org = shift;

$y -= 10;
$product =~ s/$c/X/i;
my @args = split /X/, $product;
$fnt = $pdf->corefont('Arial',-encoding => 'latin1');
foreach my $v (@args) {
next if( $cnt++ > 2 );
$v =~ s/^\s+//;
$v =~ s/\s+$//;
$v = $v."\""; # "
print FO $v." "x( 8 - length( $v ));
$line++;
paging;
$gfx->textlabel( $x, $y, $fnt, $Mfnt, $v, -color=>[0.2]);
$x += 56;
}
paging;
my ( $xx, $yy ) = split /\./, $ref{ $name }{ WtFt }{ $org }[ 0 ];
if( length( $xx) == 1 ) {
print FO " $ref{ $name }{ WtFt }{ $org }[ 0 ]\n";
$gfx->textlabel( $x, $y, $fnt, $Mfnt, " ".$ref{ $name }{ WtFt }
{ $org }[ 0 ], -color=>[0.2]);
}else{
print FO "$ref{ $name }{ WtFt }{ $org }[ 0 ]\n"; # $line\n";
$gfx->textlabel( $x, $y, $fnt, $Mfnt, $ref{ $name }{ WtFt }
{ $org }[ 0 ], -color=>[0.2]);
}
$x = 72 + $col;
$line++;
return $cnt;
}

sub shape {
my $name = shift;
my $shape = shift;

$pdf = PDF::API2->new(-file => "w:\\sku_$name.pdf");
print FO "$shape\n";
$ref{ $name }{ shape }[ 0 ] = 1;
$line++;

$pdf->mediabox( $xmax, $ymax );
$page = $pdf->page;
$fnt = $pdf->corefont('Arial-Bold',-encoding => 'latin1');
$gfx = $page->gfx;
$gfx->textlabel( $x, $y, $fnt, $Sfnt, $shape, -color=>[0.2]);
}

sub metal {
my $name = shift;
my $metal = shift;

print FO "\n$metal\n";
$ref{ $name }{ metal }[ 0 ] = 1;
$line++;
paging;
$fnt = $pdf->corefont('Arial-BoldItalic',-encoding => 'latin1');
$gfx->textlabel( $x, $y -= 20, $fnt, $Mfnt, $metal, -
color=>[0.2]);
}

.



Relevant Pages

  • sitemap generator for Perl
    ... I want to run the sitemap generator ... Returns the minimum number of links to traverse from the root URL of ... my $class = shift; ...
    (perl.beginners)
  • Re: How can I create instantiable objects (not classes)?
    ... a child object inherits not only its parent object's ... sub fee { ... my $class = shift; ... For example, an object of type Car might receive a message named "ticket," and since a car does not know what to do with a ticket, it would pass that message to an object of type Driver. ...
    (comp.lang.perl.misc)
  • Re: Packages and returning errors
    ... > array intact. ... sub is_a_instance_method { ... my $class = shift; ... You need to fix the scope of $error by moving its declaration outside ...
    (comp.lang.perl.misc)
  • Re: passing database data to a sub
    ... > I'm not sure of the difference, why isn't it a subroutine? ... > sure about this 'shift' thing anyway :-) ... > sub teardown ... > # Setup the template to use for the output. ...
    (perl.beginners)
  • Re: Massive failed FTP attempts.
    ... made it a little more generic so that it could monitor any log file. ... To run as a daemon and monitor proftpd, sending lockout notifications to ... sub prune_old_entries ... my $line = shift; ...
    (Security-Basics)