r809 - in packages/libpdf-report-perl/trunk: . debian examples

Gunnar Wolf gwolf@costa.debian.org
Fri, 18 Mar 2005 02:09:23 +0100


Author: gwolf
Date: 2005-03-18 02:09:22 +0100 (Fri, 18 Mar 2005)
New Revision: 809

Added:
   packages/libpdf-report-perl/trunk/examples/image
   packages/libpdf-report-perl/trunk/examples/image.gif
   packages/libpdf-report-perl/trunk/examples/image.jpg
   packages/libpdf-report-perl/trunk/examples/image.png
   packages/libpdf-report-perl/trunk/examples/image.pnm
   packages/libpdf-report-perl/trunk/examples/image.tif
Modified:
   packages/libpdf-report-perl/trunk/Changes
   packages/libpdf-report-perl/trunk/MANIFEST
   packages/libpdf-report-perl/trunk/Makefile.PL
   packages/libpdf-report-perl/trunk/README
   packages/libpdf-report-perl/trunk/Report.pm
   packages/libpdf-report-perl/trunk/debian/changelog
   packages/libpdf-report-perl/trunk/examples/barcode
   packages/libpdf-report-perl/trunk/examples/paragraph
Log:
New upstream version 1.30


Modified: packages/libpdf-report-perl/trunk/Changes
===================================================================
--- packages/libpdf-report-perl/trunk/Changes	2005-03-18 01:03:31 UTC (rev 808)
+++ packages/libpdf-report-perl/trunk/Changes	2005-03-18 01:09:22 UTC (rev 809)
@@ -1,5 +1,9 @@
 Revision history for Perl extension PDF::Report.
 
+1.30  Fri Mar  4 12:19:32 EST 2005
+	- Patched most of the subroutines for PDF-API2-0.40.xx
+	- Added an image example
+
 1.22  Wed Jan 26 09:21:15 EST 2005
 	- Corrected suppression of zeros when using addText
 

Modified: packages/libpdf-report-perl/trunk/MANIFEST
===================================================================
--- packages/libpdf-report-perl/trunk/MANIFEST	2005-03-18 01:03:31 UTC (rev 808)
+++ packages/libpdf-report-perl/trunk/MANIFEST	2005-03-18 01:09:22 UTC (rev 809)
@@ -1,13 +1,19 @@
-Report.pm
 Changes
 LICENSE
 MANIFEST
+Makefile.PL
 README
-Makefile.PL
-test.pl
-examples/piegraph
-examples/paragraph
+Report.pm
 examples/barcode
+examples/footer
+examples/image
+examples/image.gif
+examples/image.jpg
+examples/image.png
+examples/image.pnm
+examples/image.tif
 examples/openpdf
-examples/footer
+examples/paragraph
+examples/piegraph
 examples/rotate
+test.pl

Modified: packages/libpdf-report-perl/trunk/Makefile.PL
===================================================================
--- packages/libpdf-report-perl/trunk/Makefile.PL	2005-03-18 01:03:31 UTC (rev 808)
+++ packages/libpdf-report-perl/trunk/Makefile.PL	2005-03-18 01:09:22 UTC (rev 809)
@@ -1,26 +1,13 @@
 use ExtUtils::MakeMaker;
 
-$PDF_API2_PREREQ = "0.3r74";
+$PDF_API2_PREREQ = "0.40.00";
 
-eval {
-  require PDF::API2;
-
-  if ($PDF::API2::VERSION lt $PDF_API2_PREREQ) {
-    print "Warning, PDF::API2 version $PDF::API2::VERSION too old!\n" .
-          "You should use at least version $PDF_API2_PREREQ\n" .
-          "Continuing anyway...\n";
-  }
-};
-
-print "PDF::API2 Doesn't seem to be installed!\n\n" 
-  if $@ =~ /Can't locate PDF\/API2\.pm/; 
-
 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
 # the contents of the Makefile that is written.
 WriteMakefile(
     'NAME'		=> 'PDF::Report',
-    'VERSION'	        => 1.22, 
-    'PREREQ_PM'		=> {PDF::API2 => '0.3r74'},
+    'VERSION'	        => 1.30, 
+    'PREREQ_PM'		=> {PDF::API2 => $PDF_API2_PREREQ},
     ($] >= 5.005 ?    ## Add these new keywords supported since 5.005
       (ABSTRACT_FROM => 'Report.pm', # retrieve abstract from module
        AUTHOR     => 'Andrew Orr <aorr@cpan.org>') : ()),

Modified: packages/libpdf-report-perl/trunk/README
===================================================================
--- packages/libpdf-report-perl/trunk/README	2005-03-18 01:03:31 UTC (rev 808)
+++ packages/libpdf-report-perl/trunk/README	2005-03-18 01:09:22 UTC (rev 809)
@@ -1,5 +1,5 @@
-Dist version 1.22 
-=================
+Dist version 1.30
+==================
 
 PDF::Report is written around Alfred Reibenschuh's PDF::API2.  It provides
 methods to create a PDF document with text, lines, color and graphics. 
@@ -17,16 +17,20 @@
 
 This module requires these other modules and libraries:
 
-  PDF::API2 >= 0.3r74
+  PDF::API2 >= 0.40.00
 
-  NOTE:  You can use an older version of PDF::API2, but don't expect things 
-         like text color, text underlining, or the addParagraph routine to work 
-         correctly if at all!  Best to use a RELEASE and not an ALPHA or BETA.
+  NOTE:	As of PDF-Report 1.30, PDF-API2 versions less than 0.40.00 are 
+        unsupported. If you want to keep using an old PDF-API2, use 
+        PDF-Report 1.2x.  
 
 Optional (If you want to use roman numerals when numbering pages):
 
   Text::Roman >= 3.02
 
+EXAMPLES 
+
+  See the examples/ directory in the distribution.
+
 COPYRIGHT AND LICENSE
 
 "Perl Artistic License" (included with package)

Modified: packages/libpdf-report-perl/trunk/Report.pm
===================================================================
--- packages/libpdf-report-perl/trunk/Report.pm	2005-03-18 01:03:31 UTC (rev 808)
+++ packages/libpdf-report-perl/trunk/Report.pm	2005-03-18 01:09:22 UTC (rev 809)
@@ -2,13 +2,13 @@
 # This is a wrapper for Alfred Reibenschuh's PDF::API2
 # Defines methods to create PDF reports
 # By: Andy Orr
-# Date: 01/26/2005
-# Version: 1.22
+# Date: 03/04/2005 
+# Version: 1.30
 ###############################################################################
 
 package PDF::Report;
 
-$VERSION = "1.22"; 
+$VERSION = "1.30"; 
 
 =head1 PDF::Report 
 
@@ -105,11 +105,8 @@
   }
 
   # Set the width and height of the page
-  my ($pageWidth, $pageHeight) = 
-    (PDF::API2::Util::page_size "\L$DEFAULTS{PageSize}") [2,3];
-  ($pageWidth, $pageHeight) = 
-    (PDF::API2::Util::page_size "\L$defaults{PageSize}") [2,3]
-     if length($defaults{PageSize});
+  my ($x1, $y1, $pageWidth, $pageHeight) = 
+    PDF::API2::Util::page_size($DEFAULTS{PageSize});
 
   # Swap w and h if landscape
   if (lc($DEFAULTS{PageOrientation})=~/landscape/) {
@@ -160,7 +157,7 @@
 
   # Default fonts
   $self->{font} = $self->{pdf}->corefont('Helvetica'); # Default font object
-  $self->{font}->encodeByData('latin1');
+  #$self->{font}->encode('latin1');
 
   # Set the users options
   foreach my $key (keys %defaults) {
@@ -262,14 +259,17 @@
   $indent = undef if !length($indent);
 
   my $txt = $self->{page}->text;
-  $txt->font($self->{font}, $self->{size});
-  $txt->transform_rel(-translate => [$x, $y], -rotate => $rotate);
-  $txt->text($text, -color=>[$color], -underline=>$underline,
-	     -indent=>$indent);
+#  $txt->font($self->{font}, $self->{size});
+#  $txt->transform_rel(-translate => [$x, $y], -rotate => $rotate);
+#  $txt->text($text, -color=>[$color], -underline=>$underline, 
+#                          -indent=>$indent);
+
+  $txt->textlabel($x, $y, $self->{font}, $self->{size}, $text,
+                  -rotate => $rotate,
+                  -color => $color, -underline=>$underline, -indent=>$indent);
+
 }
 
-=pod
-
 =item PDF::API2 Removes all space between every word in the string you pass 
 and then rejoins each word with one space.  If you want to use a string with 
 more than one space between words for formatting purposes, you can either use 
@@ -495,8 +495,14 @@
   my $txt = $self->{page}->text;
   $txt->font($self->{font}, $self->{size});
 
-  $txt->paragraph($text, -x => $hPos, -y => $vPos, -w => $width, 
-                  -h => $height, -flindent => $indent, -lead => $lead);
+#  $txt->paragraph($text, -x => $hPos, -y => $vPos, -w => $width, 
+#                  -h => $height, -flindent => $indent, -lead => $lead, -rel => 1);
+
+#  0.40.x
+  $txt->lead($lead); # Line spacing
+  $txt->translate($hPos,$vPos);
+  $txt->paragraph($text, $width, $height, -align=>'justified');
+
   ($self->{hPos},$self->{vPos}) = $txt->textpos;
 }
 
@@ -567,30 +573,23 @@
 
 =cut
 
-sub iobjbyext {
-  my ( $self, $file ) = @_;
-
-  # stupid hack depending on file extensions
-  my %ext = (gif  => sub { $_[0]->{pdf}->image_gif  ($_[1]) },
-             jpg  => sub { $_[0]->{pdf}->image_jpeg ($_[1]) },
-             jpeg => sub { $_[0]->{pdf}->image_jpeg ($_[1]) },
-             png  => sub { $_[0]->{pdf}->image_png  ($_[1]) },
-             pnm  => sub { $_[0]->{pdf}->image_pnm  ($_[1]) },
-             gd   => sub { $_[0]->{pdf}->image_gd   ($_[1]) },
-             tif  => sub { $_[0]->{pdf}->image_tiff ($_[1]) },
-             tiff => sub { $_[0]->{pdf}->image_tiff ($_[1]) },
-	     );
- 
-  my $fn = $ext {lc $1} if ($file||'') =~ m|\.(\w+)$| ;
-  # Treat as a .gif if we get no hint
-  $fn ||= sub { $_[0]->{pdf}->image_gif  ($_[1]) };
-  &$fn ($self, $file) ;
-}
-
 sub addImg {
   my ( $self, $file, $x, $y ) = @_;
 
-  my $img = $self->iobjbyext($file);
+  my %type = (jpeg => "jpeg", 
+              jpg  => "jpeg",
+              tif  => "tiff",
+              tiff => "tiff",
+              pnm  => "pnm",
+              gif  => "gif",
+              png  => "png",
+  ); 
+
+  $file =~ /\.(\w+)$/;
+  my $ext = $1;
+
+  my $sub = "image_$type{$ext}";
+  my $img = $self->{pdf}->$sub($file);
   my $gfx = $self->{page}->gfx;
 
   $gfx->image($img, $x, $y);
@@ -605,10 +604,12 @@
 sub addImgScaled {
   my ( $self, $file, $x, $y, $scale ) = @_;
 
-  my $img = $self->iobjbyext($file);
-  my $gfx = $self->{page}->gfx;
+#  my $img = $self->{pdf}->image($file);
+#  my $gfx = $self->{page}->gfx;
 
-  $gfx->image($img, $x, $y, $scale);
+#  $gfx->image($img, $x, $y, $scale);
+
+  $self->addImg($file, $x, $y);
 }
 
 =item $pdf->setGfxLineWidth($width);
@@ -860,9 +861,9 @@
 This is a very flexible way to draw a barcode on your PDF document.  
 $x and $y represent the center of the barcode's position on the document.  
 $scale is the size of the entire barcode 1 being 1:1, which is all you'll 
-need most likely.  $type is the type of barcode which can be 3of9, 3of9ext, 
-3of9chk, 3of9extchk, code128a, code128b, code128c, ean128, or ean13.  $code is
-the alpha-numeric code which the barcode will represent.  $extn is the 
+need most likely.  $type is the type of barcode which can be codabar, 2of5int, 
+3of9, code128, or ean13.  $code is the alpha-numeric code which the barcode 
+will represent.  $extn is the 
 extension to the $code, where applicable.  $umzn is the upper mending zone and 
 $lmzn is the lower mending zone. $zone is the the zone or height of the bars. 
 $quzn is the quiet zone or the space between the frame and the barcode.  $spcr
@@ -894,7 +895,8 @@
   my $page = $self->{page};
   my $gfx  = $page->gfx;  
 
-  my $bar = $self->{pdf}->barcode(
+  my $bSub = "xo_$type";
+  my $bar = $self->{pdf}->$bSub(
                            -font => $self->{font},
                            -type => $type,
                            -code => $code,
@@ -909,7 +911,15 @@
                            -text => $text
                           );
 
-  $gfx->barcode($bar, $x, $y, $scale, $frame);
+#  $gfx->barcode($bar, $x, $y, $scale, $frame);
+  $gfx->save;
+  $gfx->linecap(0);
+  $gfx->transform( -translate => [$x, $y]);
+  $gfx->fillcolor('#ffffff');
+  $gfx->linewidth(0.1);
+  $gfx->fill;
+  $gfx->formimage($bar,0,0);
+  $gfx->restore;
 }
 
 =item $pdf->setFont($font);
@@ -1040,7 +1050,7 @@
 
 sub Finish {
   my $self = shift;
-  my $callback = shift || 'none';
+  my $callback = shift;
 
   my $total = $self->{page_nbr} - 1;
 

Modified: packages/libpdf-report-perl/trunk/debian/changelog
===================================================================
--- packages/libpdf-report-perl/trunk/debian/changelog	2005-03-18 01:03:31 UTC (rev 808)
+++ packages/libpdf-report-perl/trunk/debian/changelog	2005-03-18 01:09:22 UTC (rev 809)
@@ -1,3 +1,9 @@
+libpdf-report-perl (1.30-1) unstable; urgency=low
+
+  * New upstream release
+
+ -- Gunnar Wolf <gwolf@debian.org>  Thu, 17 Mar 2005 18:49:54 -0600
+
 libpdf-report-perl (1.22-2) unstable; urgency=low
 
   * Fixed usage of private (and deprecated) PDF::API2 attributes which

Modified: packages/libpdf-report-perl/trunk/examples/barcode
===================================================================
--- packages/libpdf-report-perl/trunk/examples/barcode	2005-03-18 01:03:31 UTC (rev 808)
+++ packages/libpdf-report-perl/trunk/examples/barcode	2005-03-18 01:09:22 UTC (rev 809)
@@ -14,14 +14,12 @@
 
 $pdf->centerString(0, $width, $height-40, "Barcodes");
 
-my $x = $width/2;
-my $y = $height-120; 
-my @types = qw(3of9 3of9ext 3of9chk 3of9extchk code128a code128b 
-               code128c ean128 ean13);
+my $x = $width/3;
+my $y = $height-150; 
+my @types = qw(3of9 code128 ean13 codabar 2of5int);
 
-my @codes = qw(010203045678909 010203045678909 010203045678909 
-               384318530034967067 384318530034967067 384318530034967067 
-               384318530034967067 384318530034967067 384318530034967067);
+my @codes = qw(010203045678909 ABCDEFabcdef012345 010203045678909 
+               384318530034967067 384318530034967067);
 
 $pdf->setFont('Helvetica');
 $pdf->setSize(10);
@@ -36,7 +34,7 @@
   if (($types[$nbr] eq '3of9ext') or ($types[$nbr] eq '3of9extchk')) {
     $ext = 90506;
   } 
-  $pdf->centerString(0, $width, $y+50, $types[$nbr]);
+  $pdf->centerString(0, $width, $y+85, $types[$nbr]);
   $pdf->drawBarcode($x, $y, 1, 1, 
                    $types[$nbr], $codes[$nbr], $ext, 
                    10, 10, 50, 10, ' ', undef, 8, undef);

Copied: packages/libpdf-report-perl/trunk/examples/image (from rev 806, packages/libpdf-report-perl/branches/upstream/current/examples/image)

Copied: packages/libpdf-report-perl/trunk/examples/image.gif (from rev 806, packages/libpdf-report-perl/branches/upstream/current/examples/image.gif)


Property changes on: packages/libpdf-report-perl/trunk/examples/image.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Copied: packages/libpdf-report-perl/trunk/examples/image.jpg (from rev 806, packages/libpdf-report-perl/branches/upstream/current/examples/image.jpg)


Property changes on: packages/libpdf-report-perl/trunk/examples/image.jpg
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Copied: packages/libpdf-report-perl/trunk/examples/image.png (from rev 806, packages/libpdf-report-perl/branches/upstream/current/examples/image.png)


Property changes on: packages/libpdf-report-perl/trunk/examples/image.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Copied: packages/libpdf-report-perl/trunk/examples/image.pnm (from rev 806, packages/libpdf-report-perl/branches/upstream/current/examples/image.pnm)


Property changes on: packages/libpdf-report-perl/trunk/examples/image.pnm
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Copied: packages/libpdf-report-perl/trunk/examples/image.tif (from rev 806, packages/libpdf-report-perl/branches/upstream/current/examples/image.tif)


Property changes on: packages/libpdf-report-perl/trunk/examples/image.tif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: packages/libpdf-report-perl/trunk/examples/paragraph
===================================================================
--- packages/libpdf-report-perl/trunk/examples/paragraph	2005-03-18 01:03:31 UTC (rev 808)
+++ packages/libpdf-report-perl/trunk/examples/paragraph	2005-03-18 01:09:22 UTC (rev 809)
@@ -29,9 +29,9 @@
         "The computer scientist, who'd listened carefully to all of this, then 
 commented, \"Yes, but where do you think the chaos came from?\"";
 
-$pdf->addParagraph($text1, 30, $height-70, $width-60, 50, 25);
-$pdf->addParagraph($text2, 30, $height-100, $width-60, 40, 25);
-$pdf->addParagraph($text3, 30, $height-120, $width-60, 40, 25);
+$pdf->addParagraph($text1, 30, $height-70, $width-60, 30, 25, 10);
+$pdf->addParagraph($text2, 30, $height-100, $width-60, 20, 25, 10);
+$pdf->addParagraph($text3, 30, $height-120, $width-60, 20, 25, 10);
 
 open(PDF, "> $0.pdf") or die "Error opening $0.pdf: $!\n";
 print PDF $pdf->Finish();