First time using Perl & PDF::API2

[email protected] (ChrisC)
Newsgroups perl.beginners
Organization http://groups.google.com
Message-ID <6f9bcb0a-a1a6-403c-874f-9049639e3e69@f36g2000hsa.googlegroups.com>
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]);
  }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.