r679 - in packages: . libpdf-report-perl libpdf-report-perl/branches libpdf-report-perl/branches/upstream libpdf-report-perl/branches/upstream/current libpdf-report-perl/branches/upstream/current/examples

Gunnar Wolf gwolf at costa.debian.org
Sun Jul 17 08:08:57 UTC 2005


Author: gwolf
Date: 2005-01-27 17:14:41 +0100 (Thu, 27 Jan 2005)
New Revision: 679

Added:
   packages/libpdf-report-perl/
   packages/libpdf-report-perl/branches/
   packages/libpdf-report-perl/branches/upstream/
   packages/libpdf-report-perl/branches/upstream/current/
   packages/libpdf-report-perl/branches/upstream/current/Changes
   packages/libpdf-report-perl/branches/upstream/current/LICENSE
   packages/libpdf-report-perl/branches/upstream/current/MANIFEST
   packages/libpdf-report-perl/branches/upstream/current/Makefile.PL
   packages/libpdf-report-perl/branches/upstream/current/README
   packages/libpdf-report-perl/branches/upstream/current/Report.pm
   packages/libpdf-report-perl/branches/upstream/current/examples/
   packages/libpdf-report-perl/branches/upstream/current/examples/barcode
   packages/libpdf-report-perl/branches/upstream/current/examples/footer
   packages/libpdf-report-perl/branches/upstream/current/examples/openpdf
   packages/libpdf-report-perl/branches/upstream/current/examples/paragraph
   packages/libpdf-report-perl/branches/upstream/current/examples/piegraph
   packages/libpdf-report-perl/branches/upstream/current/examples/rotate
   packages/libpdf-report-perl/branches/upstream/current/test.pl
   packages/libpdf-report-perl/tags/
Log:
[svn-inject] Installing original source of libpdf-report-perl

Added: packages/libpdf-report-perl/branches/upstream/current/Changes
===================================================================
--- packages/libpdf-report-perl/branches/upstream/current/Changes	2005-01-27 16:09:40 UTC (rev 678)
+++ packages/libpdf-report-perl/branches/upstream/current/Changes	2005-01-27 16:14:41 UTC (rev 679)
@@ -0,0 +1,34 @@
+Revision history for Perl extension PDF::Report.
+
+1.22  Wed Jan 26 09:21:15 EST 2005
+	- Corrected suppression of zeros when using addText
+
+1.21  Tue Jan 25 21:50:45 EST 2005
+        - Documentation corrections
+        - Added text height parameter to addText
+        - Corrected Makefile.PL
+  ---- patch from Kaare Rasmussen ----
+        - Fixed a typo
+        - Let PDF::API2 give us x and y after calling addParagraph
+        - saveAs subroutine
+
+1.20  Fri Oct 31 10:36:26 EST 2003
+        - Added font caching
+        - Added text rotation
+        - Text::Roman is now optional
+        - Applied some helpful patches submitted by several users (thanks)
+
+1.10  Wed Apr 23 18:02:47 EDT 2003
+        - Added example scripts
+        - Cleaned up the perldoc 
+
+1.01  Wed Dec  4 15:12:16 EST 2002 (unreleased)
+	- Complete control of page footers.  (callback functions)
+        - Can open and add to existing PDF
+        - Color, underline, and indent added to addRawText()
+        - Fixed addParagragh()
+        - new drawBarcode() subroutine 
+        - new drawPieGraph() subroutine 
+
+1.00  Mon Sep 23 16:27:34 2002
+	- original version; created by Andy Orr

Added: packages/libpdf-report-perl/branches/upstream/current/LICENSE
===================================================================
--- packages/libpdf-report-perl/branches/upstream/current/LICENSE	2005-01-27 16:09:40 UTC (rev 678)
+++ packages/libpdf-report-perl/branches/upstream/current/LICENSE	2005-01-27 16:14:41 UTC (rev 679)
@@ -0,0 +1,113 @@
+			 The "Perl Artistic License"
+
+				Preamble
+
+The intent of this document is to state the conditions under which the Perl
+Package may be copied, such that the Copyright Holder maintains some
+semblance of artistic control over its development, while giving Perl users 
+the right to use and distribute Perl in a more-or-less customary fashion, 
+plus the right to make reasonable modifications.
+
+Definitions:
+
+	"Package" refers to the collection of Perl-kit files distributed by the
+	Copyright Holder, and derivatives of that collection of files
+	created through textual modification.
+
+	"Standard Version" refers to such a Package if it has not been
+	modified, or has been modified as specified below.
+
+	"Copyright Holder" is whoever is named in the copyright or
+	copyrights for the Perl package.
+
+	"You" is you, if you're thinking about copying or distributing
+	this Package.
+
+	"Reasonable copying fee" is whatever you can justify on the
+	basis of media cost, duplication charges, time of people involved,
+	and so on.  (You will not be required to justify it to the
+	Copyright Holder, but only to the computing community at large
+	as a market that must bear the fee.)
+
+	"Freely Available" means that no fee is charged for the item
+	itself, though there may be fees involved in handling the item.
+	It also means that recipients of the item may redistribute it
+	under the same conditions they received it.
+
+1. You may make and give away verbatim copies of the source form of the
+Standard Version of this Perl Package without restriction, provided that you
+duplicate all of the original copyright notices and associated disclaimers.
+
+2. You may apply bug fixes, portability fixes and other modifications
+derived from the Public Domain or from the Copyright Holder.  A Package
+modified in such a way shall still be considered the Standard Version.
+
+3. You may otherwise modify your copy of this Perl Package in any way, 
+provided that you insert a prominent notice in each changed file stating how 
+and when you changed that file, and provided that you do at least ONE of the
+following:
+
+    a) place your modifications in the Public Domain or otherwise make them
+    Freely Available, such as by posting said modifications to Usenet or
+    an equivalent medium, or placing the modifications on a major archive
+    site such as uunet.uu.net, or by allowing the Copyright Holder to include
+    your modifications in the Standard Version of the Perl Package.
+
+    b) use the modified Perl Package only within your corporation or 
+	organization.
+
+    c) rename any non-standard executables so the names do not conflict
+    with standard executables, which must also be provided, and provide
+    a separate manual page for each non-standard executable that clearly
+    documents how it differs from the Standard Version.
+
+    d) make other distribution arrangements with the Copyright Holder.
+
+4. You may distribute the programs of this Perl Package in object code or
+executable form, provided that you do at least ONE of the following:
+
+    a) distribute a Standard Version of the executables and library files,
+    together with instructions (in the manual page or equivalent) on where
+    to get the Standard Version.
+
+    b) accompany the distribution with the machine-readable source of
+    the Perl Package with your modifications.
+
+    c) accompany any non-standard executables with their corresponding
+    Standard Version executables, giving the non-standard executables
+    non-standard names, and clearly documenting the differences in manual
+    pages (or equivalent), together with instructions on where to get
+    the Standard Version.
+
+    d) make other distribution arrangements with the Copyright Holder.
+
+5. You may charge a reasonable copying fee for any distribution of this
+Perl Package.  You may charge any fee you choose for support of this Perl 
+Package. You may not charge a fee for this Perl Package itself.  However,
+you may distribute this Perl Package in aggregate with other (possibly
+commercial) programs as part of a larger (possibly commercial) software
+distribution provided that you do not advertise this Perl Package as a
+product of your own.
+
+6. The scripts and library files supplied as input to or produced as
+output from the programs of this Perl Package do not automatically fall
+under the copyright of this Perl Package, but belong to whomever generated
+them, and may be sold commercially, and may be aggregated with this Perl
+Package.
+
+7. C subroutines supplied by you and linked into this Perl Package in order
+to emulate subroutines and variables of the language defined by this Perl
+Package shall not be considered part of this Perl Package, but are the
+equivalent of input as in Paragraph 6, provided these subroutines do
+not change the language in any way that would cause it to fail the
+regression tests for the language.
+
+8. The name of the Copyright Holder may not be used to endorse or promote
+products derived from this software without specific prior written permission.
+
+9. This PERL PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+				The End
+

Added: packages/libpdf-report-perl/branches/upstream/current/MANIFEST
===================================================================
--- packages/libpdf-report-perl/branches/upstream/current/MANIFEST	2005-01-27 16:09:40 UTC (rev 678)
+++ packages/libpdf-report-perl/branches/upstream/current/MANIFEST	2005-01-27 16:14:41 UTC (rev 679)
@@ -0,0 +1,13 @@
+Report.pm
+Changes
+LICENSE
+MANIFEST
+README
+Makefile.PL
+test.pl
+examples/piegraph
+examples/paragraph
+examples/barcode
+examples/openpdf
+examples/footer
+examples/rotate

Added: packages/libpdf-report-perl/branches/upstream/current/Makefile.PL
===================================================================
--- packages/libpdf-report-perl/branches/upstream/current/Makefile.PL	2005-01-27 16:09:40 UTC (rev 678)
+++ packages/libpdf-report-perl/branches/upstream/current/Makefile.PL	2005-01-27 16:14:41 UTC (rev 679)
@@ -0,0 +1,27 @@
+use ExtUtils::MakeMaker;
+
+$PDF_API2_PREREQ = "0.3r74";
+
+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'},
+    ($] >= 5.005 ?    ## Add these new keywords supported since 5.005
+      (ABSTRACT_FROM => 'Report.pm', # retrieve abstract from module
+       AUTHOR     => 'Andrew Orr <aorr at cpan.org>') : ()),
+);

Added: packages/libpdf-report-perl/branches/upstream/current/README
===================================================================
--- packages/libpdf-report-perl/branches/upstream/current/README	2005-01-27 16:09:40 UTC (rev 678)
+++ packages/libpdf-report-perl/branches/upstream/current/README	2005-01-27 16:14:41 UTC (rev 679)
@@ -0,0 +1,34 @@
+Dist version 1.22 
+=================
+
+PDF::Report is written around Alfred Reibenschuh's PDF::API2.  It provides
+methods to create a PDF document with text, lines, color and graphics. 
+
+INSTALLATION
+
+To install this module type the following:
+
+   perl Makefile.PL
+   make
+   make test
+   make install
+
+DEPENDENCIES
+
+This module requires these other modules and libraries:
+
+  PDF::API2 >= 0.3r74
+
+  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.
+
+Optional (If you want to use roman numerals when numbering pages):
+
+  Text::Roman >= 3.02
+
+COPYRIGHT AND LICENSE
+
+"Perl Artistic License" (included with package)
+
+Copyright (C) 2005 Andrew Orr

Added: packages/libpdf-report-perl/branches/upstream/current/Report.pm
===================================================================
--- packages/libpdf-report-perl/branches/upstream/current/Report.pm	2005-01-27 16:09:40 UTC (rev 678)
+++ packages/libpdf-report-perl/branches/upstream/current/Report.pm	2005-01-27 16:14:41 UTC (rev 679)
@@ -0,0 +1,1078 @@
+###############################################################################
+# 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
+###############################################################################
+
+package PDF::Report;
+
+$VERSION = "1.22"; 
+
+=head1 PDF::Report 
+
+=head1 NAME
+
+PDF::Report - A wrapper written for PDF::API2
+
+=head1 SYNOPSIS
+	
+	use PDF::Report;
+
+        my $pdf = new PDF::Report(%opts);
+
+=cut
+
+use strict;
+use PDF::API2;
+
+### GLOBAL SECTION ############################################################
+# Sane defaults
+my %DEFAULTS;
+$DEFAULTS{PageSize}='letter';
+$DEFAULTS{PageOrientation}='Portrait';
+$DEFAULTS{Compression}=1;
+$DEFAULTS{PdfVersion}=3;
+$DEFAULTS{marginX}=30;
+$DEFAULTS{marginY}=30;
+$DEFAULTS{font}="Helvetica";
+$DEFAULTS{size}=12;
+
+my ( $day, $month, $year )= ( localtime( time ) )[3..5];
+my $DATE=sprintf "%02d/%02d/%04d", ++$month, $day, 1900 + $year;
+
+# Document info
+my %INFO = 
+          (
+            Creator => "None",
+            Producer => "None",
+            CreationDate => $DATE,
+            Title => "Untitled",
+            Subject => "None",
+            Author => "Auto-generated",
+          );
+
+my @parameterlist=qw(
+        PageSize
+        PageWidth
+        PageHeight
+        PageOrientation
+        Compression
+        PdfVersion
+);
+### END GLOBALS ###############################################################
+
+### GLOBAL SUBS ############################################################### 
+
+=head1 METHODS
+
+=item my $pdf = new PDF::Report(%opts);
+
+	Creates a new pdf report object.  
+        If no %opts are specified the module 
+        will use the factory defaults.
+
+B<Example:>
+
+	my $pdf = new PDF::Report(PageSize => "letter", 
+                                  PageOrientation => "Landscape");
+
+        my $pdf = new PDF::Report(File => $file);
+
+%opts:
+	
+        PageSize - '4A', '2A', 'A0', 'A1', 'A2',
+                   'A3', 'A4', 'A5', 'A6', '4B', 
+                   '2B', 'B0', 'B1', 'B2', 'B3', 
+                   'B4', 'B5', 'B6', 'LETTER', 
+                   'BROADSHEET', 'LEDGER', 'TABLOID', 
+                   'LEGAL', 'EXECUTIVE', '36X36'
+
+	PageOrientation - 'Portrait', 'Landscape'
+
+=cut
+
+# Create a new PDF document
+sub new {
+  my $class    = shift;
+  my %defaults = @_;
+
+  foreach my $dflt (@parameterlist) {
+    if (defined($defaults{$dflt})) {
+      $DEFAULTS{$dflt} = $defaults{$dflt}; # Overridden from user
+    }
+  }
+
+  # Set the width and height of the page
+  my ($pageWidth, $pageHeight) = 
+    @{$PDF::API2::Page::pgsz{"\L$DEFAULTS{PageSize}"}};
+  ($pageWidth, $pageHeight) = 
+    @{$PDF::API2::Page::pgsz{"\L$defaults{PageSize}"}} 
+     if length($defaults{PageSize});
+
+  # Swap w and h if landscape
+  if (lc($DEFAULTS{PageOrientation})=~/landscape/) {
+    my $tempW = $pageWidth;
+    $pageWidth = $pageHeight;
+    $pageHeight = $tempW;
+    $tempW = undef;
+  }
+
+  my $MARGINX = $DEFAULTS{marginX};
+  my $MARGINY = $DEFAULTS{marginY};
+
+  # May not need alot of these, will review later
+  my $self= { #pdf          => PDF::API2->new(),
+              hPos         => undef,
+              vPos         => undef,
+              size         => 12,    # Default
+              font         => undef, # the font object
+              PageWidth    => $pageWidth,
+              PageHeight   => $pageHeight,
+              Xmargin      => $MARGINX,
+              Ymargin      => $MARGINY,
+              BodyWidth    => $pageWidth - $MARGINX * 2,
+              BodyHeight   => $pageHeight - $MARGINY * 2,
+              page         => undef, # the current page object
+              page_nbr     => 1,
+              align        => 'left',
+              linewidth    => 1,
+              linespacing  => 0,
+              FtrFontName  => 'Helvetica-Bold',
+              FtrFontSize  => 11,
+              MARGIN_DEBUG => 0,
+              PDF_API2_VERSION => $PDF::API2::VERSION,
+
+              ########################################################
+              # Cache for font object caching -- used by setFont() ###
+              ########################################################
+              __font_cache => {},
+            };
+
+  if (length($defaults{File})) {
+    $self->{pdf} = PDF::API2->open($defaults{File}) 
+                     or die "$defaults{File} not found: $!\n";
+    
+  } else {
+    $self->{pdf} = PDF::API2->new();
+  } 
+
+  # Default fonts
+  $self->{font} = $self->{pdf}->corefont('Helvetica'); # Default font object
+  $self->{font}->encode('latin1');
+
+  # Set the users options
+  foreach my $key (keys %defaults) {
+    $self->{$key}=$defaults{$key};
+  }
+
+  bless $self, $class;
+
+  return $self;
+}
+
+=item $pdf->newpage($nopage);
+
+Creates a new blank page.  Pass $nopage = 1 to toggle page numbering.
+
+=cut
+
+sub newpage {
+  my $self = shift;
+  my $no_page_number = shift;
+
+  # make a new page
+  $self->{page} = $self->{pdf}->page;
+  $self->{page}->mediabox($self->{PageWidth}, $self->{PageHeight});
+
+  # Handle the page numbering if this page is to be numbered
+  my $total = $self->pages;
+  push(@{$self->{no_page_num}}, $no_page_number);
+    
+  $self->{page_nbr}++;
+  return(0);
+}
+
+=item $pdf->openpage($index);
+
+If no index is specified, this will open the last page of the document.
+
+=cut
+
+
+sub openpage {
+  my $self = shift;
+  my $index = shift;
+  my $totpgs = $self->{pdf}->pages;
+
+  $index = $totpgs if (!defined $index or
+                       $index =~ /[^\d]/ or
+                       $index > $totpgs);
+
+  $self->{page} = $self->{pdf}->openpage($index);
+}
+
+sub importpage {
+  my $self = shift;
+  my $sourcepdf = shift;
+  my $sourceindex = shift;
+  my $targetindex = shift;  # can be a page object
+
+#  my $source = $self->{pdf}->open($sourcepdf); 
+
+  $self->{page} = $self->{pdf}->importpage($sourcepdf, $sourceindex,
+                                           $targetindex);
+}
+
+sub clonepage {
+  my $self = shift;
+  my $sourceindex = shift;
+  my $targetindex = shift;
+
+  $self->{page} = $self->{pdf}->clonepage($sourceindex, $targetindex); 
+
+}
+
+=item ($pagewidth, $pageheight) = $pdf->getPageDimensions();
+
+Returns the width and height of the page according to what page size chosen
+in "new".
+
+=cut
+
+sub getPageDimensions {
+  my $self = shift;
+ 
+   return($self->{PageWidth}, $self->{PageHeight});
+}
+
+=item $pdf->addRawText($text, $x, $y, $color, $underline, $indent, $rotate);
+
+Add $text at position $x, $y with $color, $underline, $indent and/or $rotate. 
+
+=cut
+
+# This positions string $text at $x, $y
+sub addRawText {
+  my ( $self, $text, $x, $y, $color, $underline, $indent, $rotate ) = @_;
+
+  $color = undef if !length($color);
+  $underline = undef if !length($underline);
+  $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_fancy($text, -color=>[$color], -underline=>$underline, 
+                          -indent=>$indent);
+}
+
+=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 
+the hack below or change PDF::API2 (that's what I did ;).  The code below may
+or may not work according to what font you are using.  I used 2 \xA0 per space 
+because that worked for the Helvetica font I was using. 
+
+=item B<To use a fixed width string with more than one space between words, you can do something like:>
+
+sub replaceSpace {
+  my $text = shift;
+  my $nbsp = "\xA0";
+  my $new = '';
+  my @words = split(/ /, $text);
+  foreach my $word (@words) {
+    if (length($word)) {
+      $new.=$word . ' ';
+    } else {
+      $new.=$nbsp . $nbsp;
+    }
+  } 
+  chop($new);
+  return $new;
+}
+
+=cut
+
+=item $pdf->setAddTextPos($hPos, $vPos);
+
+Set the position on the page.  Used by the addText function.
+
+=cut
+
+sub setAddTextPos {
+  my ($self, $hPos, $vPos) = @_;
+  $self->{hPos}=$hPos;
+  $self->{vPos}=$vPos;
+}
+
+=item ($hPos, $vPos) = $pdf->getAddTextPos();
+
+Return the (x, y) value of the text position.
+
+=cut
+
+sub getAddTextPos {
+  my ($self) = @_;
+  return($self->{hPos}, $self->{vPos});
+}
+
+=item $pdf->setAlign($align);
+
+Set the justification of the text.  Used by the addText function.
+
+=cut
+
+sub setAlign {
+  my $self = shift;
+  my $align = lc(shift);
+
+  if ($align=~m/^left$|^right$|^center$/) {
+    $self->{align}=$align;
+    $self->{hPos}=undef;        # Clear addText()'s tracking of hPos
+  }
+}
+
+=item $align = $pdf->getAlign();
+
+Returns the text justification.
+
+=cut
+
+sub getAlign {
+  my $self= shift @_;
+  return($self->{align});
+}
+
+=item $newtext = $pdf->wrapText($text, $width); 
+
+This is a helper function called by addText, which can be called by itself.
+wrapText() wraps $text within $width.
+
+=cut
+
+sub wrapText {
+  my $self = shift;
+  my $text = shift;
+  my $width = shift;
+
+  $text = '' if !length($text);
+
+  return $text if ($text =~ /\n/);  # We don't wrap text with carriage returns
+  return $text unless defined $width;  # If no width was specified, return text
+
+  my $txt = $self->{page}->text;
+  $txt->font($self->{font}, $self->{size});
+
+  my $ThisTextWidth=$txt->advancewidth($text);
+  return $text if ( $ThisTextWidth <= $width);
+
+  my $widSpace = $txt->advancewidth('t');  # 't' closest width to a space
+
+  my $currentWidth = 0;
+  my $newText = "";
+  foreach ( split / /, $text ) {
+    my $strWidth = $txt->advancewidth($_);
+    if ( ( $currentWidth + $strWidth ) > $width ) {
+      $currentWidth = $strWidth + $widSpace;
+      $newText .= "\n$_ ";
+    } else {
+      $currentWidth += $strWidth + $widSpace;
+      $newText .= "$_ ";
+    }
+  }
+
+  return $newText;
+}
+
+=item $pdf->addText($text, $hPos, $textWidth, $textHeight); 
+
+Takes $text and prints it to the current page at $hPos.  You may just want 
+to pass this function $text if the text is "pre-wrapped" and setAddTextPos 
+has been called previously.  Pass a $hPos to change the position the text 
+will be printed on the page.  Pass a  $textWidth and addText will wrap the 
+text for you.  $textHeight controls the row height.
+
+=cut
+
+sub addText {
+  my ( $self, $text, $hPos, $textWidth, $textHeight )= @_;
+
+  my $txt = $self->{page}->text;
+  $txt->font($self->{font}, $self->{size});
+
+  # Push the margin on for align=left (need to work on align=right)
+  if ( ($hPos=~/^[0-9]+([.][0-9]+)?$/) && ($self->{align}=~ /^left$/i) ) {
+    $self->{hPos}=$hPos + $self->{Xmargin};
+  }
+
+  # Establish a proper $self->{hPos} if we don't have one already
+  if ($self->{hPos} !~ /^[0-9]+([.][0-9]+)?$/) {
+    if ($self->{align}=~ /^left$/i) {
+      $self->{hPos} = $self->{Xmargin};
+    } elsif ($self->{align}=~ /^right$/i) {
+      $self->{hPos} = $self->{PageWidth} - $self->{Xmargin};
+    } elsif ($self->{align}=~ /^center$/i) {
+      $self->{hPos} = int($self->{PageWidth} / 2);
+    }
+  }
+
+  # If the user did not give us a $textWidth, use the distance
+  # from $hPos to the right margin as the $textWidth for align=left,
+  # use the distance from $hPos back to the left margin for align=right
+  if ( ($textWidth !~ /^[0-9]+$/) && ($self->{align}=~ /^left$/i) ) {
+    $textWidth = $self->{BodyWidth} - $self->{hPos} + $self->{Xmargin};
+  } elsif ( ($textWidth !~ /^[0-9]+$/) && ($self->{align}=~ /^right$/i) ) {
+    $textWidth = $self->{hPos} + $self->{Xmargin};
+  } elsif ( ($textWidth !~ /^[0-9]+$/) && ($self->{align}=~ /^center$/i) ) {
+    my $textWidthL=$self->{BodyWidth} - $self->{hPos} + $self->{Xmargin};
+    my $textWidthR=$self->{hPos} + $self->{Xmargin};
+    $textWidth = $textWidthL;
+    if ($textWidthR < $textWidth) { $textWidth = $textWidthR; }
+    $textWidth = $textWidth * 2;
+  }
+
+  # If $self->{vPos} is not set calculate it (on first text add)
+  if ( ($self->{vPos} == undef) || ($self->{vPos} == 0) ) {
+    $self->{vPos} = $self->{PageHeight} - $self->{Ymargin} - $self->{size};
+  }
+
+  # If the text has no carrige returns we may need to wrap it for the user
+  if ( $text !~ /\n/ ) {
+    $text = $self->wrapText($text, $textWidth);
+  }
+
+  if ( $text !~ /\n/ ) {
+    # Determine the width of this text
+    my $thistextWidth = $txt->advancewidth($text);
+
+    # If align ne 'left' (the default) then we need to recalc the xPos
+    # for this call to addRawText()  -- needs attention
+    my $xPos=$self->{hPos};
+    if ($self->{align}=~ /^right$/i) {
+      $xPos=$self->{hPos} - $thistextWidth;
+    } elsif ($self->{align}=~ /^center$/i) {
+      $xPos=$self->{hPos} - $thistextWidth / 2;
+    }
+    $self->addRawText($text,$xPos,$self->{vPos});
+
+    $thistextWidth = -1 * $thistextWidth if ($self->{align}=~ /^right$/i);
+    $thistextWidth = -1 * $thistextWidth / 2 if ($self->{align}=~ /^center$/i);
+    $self->{hPos} += $thistextWidth;
+  } else {
+    $text=~ s/\n/\0\n/g;                # This copes w/strings of only "\n"
+    my @lines= split /\n/, $text;
+    foreach ( @lines ) {
+      $text= $_;
+      $text=~ s/\0//;
+      if (length( $text )) {
+        $self->addRawText($text, $self->{hPos}, $self->{vPos});
+      }
+      if (($self->{vPos} - $self->{size}) < $self->{Ymargin}) {
+        $self->{vPos} = $self->{PageHeight} - $self->{Ymargin} - $self->{size};
+        $self->newpage;
+      } else {
+        $textHeight = $self->{size} unless $textHeight;
+        $self->{vPos} -= $self->{size} - $self->{linespacing};
+      }
+    }
+  }
+}
+
+=item $pdf->addParagraph($text, $hPos, $vPos, $width, $height, $indent, $lead);
+
+Add $text at ($hPos, $vPos) within $width and $height, with $indent.  
+$indent is the number of spaces at the beginning of the first line.
+
+=cut
+
+sub addParagraph {
+  my ( $self, $text, $hPos, $vPos, $width, $height, $indent, $lead ) = @_;
+
+  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);
+  ($self->{hPos},$self->{vPos}) = $txt->textpos;
+}
+
+# Backwards compatibility for that pesky typo
+sub addParagragh {
+  my ( $self, $text, $hPos, $vPos, $width, $height, $indent, $lead ) = @_;
+
+  $self->addParagraph($text, $hPos, $vPos, $width, $height, $indent, $lead);
+}
+
+=item $pdf->centerString($a, $b, $yPos, $text); 
+
+Centers $text between points $a and $b at position $yPos.  Be careful how much 
+text you try to jam between those points, this function shrinks the text till
+it fits!
+
+=cut
+
+sub centerString {  ### CENTERS STRING BETWEEN TWO POINTS
+  my $self = shift;
+  my $PointBegin = shift;
+  my $PointEnd = shift;
+  my $YPos = shift;
+  my $String = shift;
+ 
+  my $OldTextSize = $self->getSize;
+  my $TextSize = $OldTextSize;
+
+  my $Area = $PointEnd - $PointBegin;
+ 
+  my $StringWidth;
+  while (($StringWidth = $self->getStringWidth($String)) > $Area) {
+    $self->setSize(--$TextSize);  ### DECREASE THE FONTSIZE TO MAKE IT FIT
+  }
+
+  my $Offset = ($Area - $StringWidth) / 2;
+  $self->addRawText("$String",$PointBegin+$Offset,$YPos);
+  $self->setSize($OldTextSize);
+} 
+
+sub setRowHeight {
+  my $self = shift;
+  my $size = shift; # the fontsize
+
+  return (int($size * 1.20));
+}
+
+=item $pdf->getStringWidth($String); 
+
+Returns the width of $String according to the current font and fontsize being 
+used.
+
+=cut
+
+# replaces silly $pdf->{pdf}->calcTextWidth calls    
+sub getStringWidth {
+  my $self = shift;
+  my $String = shift;
+
+  my $txt = $self->{page}->text;
+  $txt->font($self->{font}, $self->{size});
+  return $txt->advancewidth($String);
+}
+
+=item $pdf->addImg($file, $x, $y); 
+
+Add image $file to the current page at position ($x, $y).
+
+=cut
+
+sub addImg {
+  my ( $self, $file, $x, $y ) = @_;
+
+  my $img = $self->{pdf}->image($file);
+  my $gfx = $self->{page}->gfx;
+
+  $gfx->image($img, $x, $y);
+}
+
+=item $pdf->addImgScaled($file, $x, $y, $scale); 
+
+Add image $file to the current page at position ($x, $y) scaled to $scale.
+
+=cut
+
+sub addImgScaled {
+  my ( $self, $file, $x, $y, $scale ) = @_;
+
+  my $img = $self->{pdf}->image($file);
+  my $gfx = $self->{page}->gfx;
+
+  $gfx->image($img, $x, $y, $scale);
+}
+
+=item $pdf->setGfxLineWidth($width);
+
+Set the line width drawn on the page.
+
+=cut
+
+sub setGfxLineWidth {
+  my ( $self, $width ) = @_;
+
+  $self->{linewidth} = $width;
+}
+
+=item $width = $pdf->getGfxLineWidth();
+
+Returns the current line width.
+
+=cut
+
+sub getGfxLineWidth {
+  my $self = shift;
+
+  return $self->{linewidth};
+}
+
+=item $pdf->drawLine($x1, $y1, $x2, $y2); 
+
+Draw a line on the current page starting at ($x1, $y1) and ending 
+at ($x2, $y2).
+
+=cut
+
+sub drawLine {
+  my ( $self, $x1, $y1, $x2, $y2 ) = @_;
+
+  my $gfx = $self->{page}->gfx;
+  $gfx->move($x1, $y1);
+  $gfx->linewidth($self->{linewidth});
+  $gfx->line($x2, $y2);
+  $gfx->stroke;
+}
+
+=item $pdf->drawRect($x1, $y1, $x2, $y2); 
+
+Draw a rectangle on the current page.  Top left corner is represented by
+($x1, $y1) and the bottom right corner is ($x2, $y2).
+
+=cut
+
+sub drawRect { 
+  my ( $self, $x1, $y1, $x2, $y2 ) = @_;
+
+  my $gfx = $self->{page}->gfx;
+  $gfx->linewidth($self->{linewidth});
+  $gfx->rectxy($x1, $y1, $x2, $y2);
+  $gfx->stroke;
+}
+
+=item $pdf->shadeRect($x1, $y1, $x2, $y2, $color);
+
+Shade a rectangle with $color.  Top left corner is ($x1, $y1) and the bottom 
+right corner is ($x2, $y2).
+
+=cut
+
+=item B<Defined color-names are:>
+
+aliceblue, antiquewhite, aqua, aquamarine, azure,
+beige, bisque, black, blanchedalmond, blue,
+blueviolet, brown, burlywood, cadetblue, chartreuse,
+chocolate, coral, cornflowerblue, cornsilk, crimson,
+cyan, darkblue, darkcyan, darkgoldenrod, darkgray,
+darkgreen, darkgrey, darkkhaki, darkmagenta,
+darkolivegreen, darkorange, darkorchid, darkred,
+darksalmon, darkseagreen, darkslateblue, darkslategray,
+darkslategrey, darkturquoise, darkviolet, deeppink,
+deepskyblue, dimgray, dimgrey, dodgerblue, firebrick,
+floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite,
+gold, goldenrod, gray, grey, green, greenyellow,
+honeydew, hotpink, indianred, indigo, ivory, khaki,
+lavender, lavenderblush, lawngreen, lemonchiffon,
+lightblue, lightcoral, lightcyan, lightgoldenrodyellow,
+lightgray, lightgreen, lightgrey, lightpink, lightsalmon,
+lightseagreen, lightskyblue, lightslategray,
+lightslategrey, lightsteelblue, lightyellow, lime,
+limegreen, linen, magenta, maroon, mediumaquamarine,
+mediumblue, mediumorchid, mediumpurple, mediumseagreen,
+mediumslateblue, mediumspringgreen, mediumturquoise,
+mediumvioletred, midnightblue, mintcream, mistyrose,
+moccasin, navajowhite, navy, oldlace, olive, olivedrab,
+orange, orangered, orchid, palegoldenrod, palegreen,
+paleturquoise, palevioletred, papayawhip, peachpuff,
+peru, pink, plum, powderblue, purple, red, rosybrown,
+royalblue, saddlebrown, salmon, sandybrown, seagreen,
+seashell, sienna, silver, skyblue, slateblue, slategray,
+slategrey, snow, springgreen, steelblue, tan, teal,
+thistle, tomato, turquoise, violet, wheat, white,
+whitesmoke, yellow, yellowgreen
+
+or the rgb-hex-notation:
+
+	#rgb, #rrggbb, #rrrgggbbb and #rrrrggggbbbb
+
+or the cmyk-hex-notation:
+
+        %cmyk, %ccmmyykk, %cccmmmyyykkk and %ccccmmmmyyyykkkk
+
+and additionally the hsv-hex-notation:
+
+        !hsv, !hhssvv, !hhhsssvvv and !hhhhssssvvvv
+
+=cut
+
+sub shadeRect {  
+  my ( $self, $x1, $y1, $x2, $y2, $color ) = @_;
+
+  my $gfx = $self->{page}->gfx;
+
+  $gfx->fillcolor($color);
+  $gfx->rectxy($x1, $y1, $x2, $y2);
+  $gfx->fill;
+}
+
+=item $pdf->drawPieGraph($x, $y, $size, $rData, $rLabels);
+
+Method to create a piegraph using a reference to an array of values.
+It also takes a reference to an array for labels for each data value.  A 
+legend with all the colors and labels will appear if $rLabels is passed. $x and
+$y are the coordinates for the center of the pie and $size is the radius.  
+
+=cut
+
+sub drawPieGraph {
+  my $self  = shift;
+  my $x     = shift;
+  my $y     = shift;
+  my $size  = shift;
+  my $rData = shift;
+  my $rLabels = shift;
+
+  my $circ = 360;  
+  my $a = 0;
+  my $b = 0;
+  my @colors = &getcolors();
+  my $lastclr = $#colors;
+  my $gfx = $self->{page}->gfx;
+
+  # Set up the colors we'll use
+  my @clr;
+  foreach my $elem ( 0 .. $#$rData ) {
+#    push(@clr, $colors[int(rand($#colors))]);  
+     push(@clr, $colors[$elem]);
+  }
+
+  # Add up the numbers
+  my $total;
+  foreach my $elem ( 0 .. $#$rData ) {
+    $total+=$rData->[$elem];
+  }
+  # Get the percentages
+  my @perc;
+  foreach my $elem ( 0 .. $#$rData ) {
+    $perc[$elem] = $rData->[$elem] / $total; 
+  }
+
+  # Draw a pie
+  my $cnt = 0;
+  foreach my $pct (@perc) {
+    $b+=$circ * $pct;
+    $b = $circ if $b > $circ;
+    $gfx->fillcolor($clr[$cnt++]);
+    $gfx->pie($x, $y, $size, $size, $a, $b);
+    $gfx->fill;
+    $a = $b;
+  }
+
+  # Do we print labels?
+  if (scalar(@{ $rLabels })) {
+    my $oldfont = $self->getFont();
+    my $oldsize = $self->getSize();
+    my $fontsize = 12;
+    $self->setFont("Times-roman");
+    $self->setSize($fontsize);
+    my $colorblocksize = 10;
+    my $maxsize = 0;
+    for (0 .. $#$rLabels) { 
+      $maxsize = $self->getStringWidth($rLabels->[$_]) 
+                   if $self->getStringWidth($rLabels->[$_]) > $maxsize; 
+    }
+    my $top = $y + ((($#perc + 1) * $fontsize) / 2);
+    my $left = $x + $size + 8;
+    $self->drawRect($left, $top,
+                    $x + $size + 8 + $colorblocksize + $maxsize + 3, 
+                    $y - ((($#perc + 1) * $fontsize) / 2)); 
+    my $pos = $top - 1;
+    $cnt = 0;
+    foreach my $nbr (0 .. $#perc) {
+      $self->shadeRect($left+1, $pos, $left+1+$colorblocksize, 
+                       $pos-$colorblocksize, $clr[$cnt++]);    
+      $self->addRawText($rLabels->[$nbr], $left+$colorblocksize+3, 
+                        $pos-$colorblocksize); 
+      $pos-=$fontsize;
+    } 
+  } 
+}
+
+sub getcolors {
+  my @cols=qw( 
+        red yellow blue green aqua bisque black  
+        blueviolet brown burlywood cadetblue chartreuse 
+        chocolate coral cornflowerblue cornsilk crimson 
+        cyan darkblue darkcyan darkgoldenrod darkgray 
+        darkgreen darkgrey darkkhaki darkmagenta 
+        darkolivegreen darkorange darkorchid darkred
+        darksalmon darkseagreen darkslateblue darkslategray
+        darkslategrey darkturquoise darkviolet deeppink 
+        deepskyblue dimgrey dodgerblue firebrick 
+        floralwhite forestgreen fuchsia gainsboro ghostwhite 
+        gold goldenrod gray greenyellow 
+        honeydew hotpink indianred indigo ivory khaki 
+        lavender lavenderblush lawngreen lemonchiffon 
+        lightblue lightcoral lightcyan lightgoldenrodyellow 
+        lightgray lightgreen lightgrey lightpink lightsalmon
+        lightseagreen lightskyblue lightslategray 
+        lightslategrey lightsteelblue lightyellow lime 
+        limegreen linen magenta maroon mediumaquamarine 
+        mediumblue mediumorchid mediumpurple mediumseagreen 
+        mediumslateblue mediumspringgreen mediumturquoise 
+        mediumvioletred midnightblue mintcream mistyrose 
+        moccasin navajowhite navy oldlace olivedrab 
+        orange orangered orchid palegoldenrod palegreen 
+        paleturquoise palevioletred papayawhip peachpuff 
+        peru pink plum powderblue purple rosybrown 
+        royalblue saddlebrown salmon sandybrown seagreen 
+        seashell sienna silver skyblue slateblue slategray 
+        slategrey snow springgreen steelblue tan teal 
+        thistle tomato turquoise violet wheat white 
+        whitesmoke yellowgreen);
+
+  return @cols;
+}
+
+=item $pdf->drawBarcode($x, $y, $scale, $frame, $type, $code, $extn, $umzn, 
+                        $lmzn, $zone, $quzn, $spcr, $ofwt, $fnsz, $text);
+
+This is really not that complicated, trust me! ;) I am pretty unfamiliar with 
+barcode lingo and types so if I get any of this wrong, lemme know! 
+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 
+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
+is what to put between each number/character in the text.  $ofwt is the 
+overflow width.  $fnsz is the fontsize used for the text.  $text is optional 
+text beneathe the barcode. 
+
+=cut
+
+sub drawBarcode {
+  my $self = shift;
+  my $x    = shift;  # x center of barcode image
+  my $y    = shift;  # y center of barcode image
+  my $scale = shift; # scale of barcode image
+  my $frame = shift; # width of the frame around the quiet zone
+#  my $font = shift;
+  my $type = shift; # type of barcode
+  my $code = shift; # the code
+  my $extn = shift; # code extension
+  my $umzn = shift; # upper mending zone
+  my $lmzn = shift; # lower mending zone
+  my $zone = shift; # height of the bars
+  my $quzn = shift; # zone between barcode and frame
+  my $spcr = shift; # space between numbers
+  my $ofwt = shift; # overflow 
+  my $fnsz = shift; # fontsize
+  my $text = shift; # alt text
+
+  my $page = $self->{page};
+  my $gfx  = $page->gfx;  
+
+  my $bar = $self->{pdf}->barcode(
+                           -font => $self->{font},
+                           -type => $type,
+                           -code => $code,
+                           -quzn => $quzn,
+                           -umzn => $umzn,
+                           -lmzn => $lmzn,
+                           -zone => $zone,
+                           -quzn => $quzn,
+                           -spcr => $spcr,
+                           -ofwt => $ofwt,
+                           -fnsz => $fnsz,
+                           -text => $text
+                          );
+
+  $gfx->barcode($bar, $x, $y, $scale, $frame);
+}
+
+=item $pdf->setFont($font);
+
+Creates a new font object of type $font to be used in the page.
+
+=cut
+
+sub setFont {
+  my ( $self, $font, $size )= @_;
+
+  if (exists $self->{__font_cache}->{$font}) {
+    $self->{font} = $self->{__font_cache}->{$font};
+  }
+  else {
+    $self->{font} = $self->{pdf}->corefont($font);
+    $self->{__font_cache}->{$font} = $self->{font};
+  }
+
+  $self->{fontname} = $font;
+}
+
+=item $fontname = $pdf->getFont();
+
+Returns the font name currently being used.
+
+=cut
+
+sub getFont {
+  my $self = shift;
+
+  return $self->{fontname};
+}
+
+=item $pdf->setSize($size); 
+
+Sets the fontsize to $size.  Called before setFont().
+
+=cut
+
+# sets the font size
+sub setSize {
+  my ( $self, $size ) = @_;
+
+  $self->{size} = $size;
+}
+
+=item $fontsize = $pdf->getSize();
+
+Returns the font size currently being used.
+
+=cut
+
+sub getSize {
+  my $self = shift;
+
+  return $self->{size};
+}
+
+# the number of pages
+sub pages {
+  my $self = shift;
+
+  return $self->{pdf}->pages;
+}
+
+=item $pdf->setInfo(%infohash);
+
+Sets the info structure of the document.  Valid keys for %infohash: 
+Creator, Producer, CreationDate, Title, Subject, Author, etc.
+
+=cut
+
+sub setInfo {
+  my ($self, %info) = @_;
+
+  # Over-ride or define %INFO values
+  foreach my $key (keys %INFO) {
+    if (length($info{$key}) and ($info{$key} ne $INFO{$key})) {
+      $INFO{$key} = $info{$key};
+    } 
+  }
+  my @orig_keys = keys(%INFO);
+  foreach my $key (keys %info) {
+    if (! grep /$key/, @orig_keys) {
+      $INFO{$key} = $info{$key};
+    }
+  }
+}
+
+=item $pdf->saveAs($fileName);
+
+Saves the document to a file.
+
+=cut
+
+=item B<Example:>
+
+       # Save the document as "file.pdf"
+        my $fileName = "file.pdf";
+       $pdf->saveAs($fileName);
+
+=cut
+
+sub saveAs {
+  my $self = shift;
+  my $fileName = shift;
+
+  $self->{pdf}->info(%INFO);
+  $self->{pdf}->saveas($fileName);
+  $self->{pdf}->end();
+}
+
+=item print $pdf->Finish(\&callback());
+
+Returns the PDF document as text.  Pass your own custom routine to do things
+on the footer of the page.  Pass 'roman' for Roman Numeral page numbering. 
+
+=cut
+
+=item B<Example:>
+
+	# Hand the document to the web browser
+	print "Content-type: application/pdf\n\n";
+	print $pdf->Finish();
+
+=cut
+
+sub Finish {
+  my $self = shift;
+  my $callback = shift;
+
+  my $total = $self->{page_nbr} - 1;
+
+  # Call the callback if one was given to us
+  if (ref($callback) eq 'CODE') {
+    &$callback($self, $total);
+  # This will print a footer if no $callback is passed for backwards 
+  # compatibility
+  } elsif ($callback !~ /none/i) {  
+    &gen_page_footer($self, $total, $callback);
+  }
+
+  $self->{pdf}->info(%INFO);
+  my $out = $self->{pdf}->stringify;
+
+  return $out;
+}
+### END GLOBAL SUBS ###########################################################
+
+### PRIVATE SUBS ##############################################################
+sub gen_page_footer {
+  my $self = shift;
+  my $total = shift;
+  my $type = shift;
+
+  for (my $i = 1; $i <= $total; $i++) {
+    next if ( $self->{no_page_num}->[$i - 1] );
+    my $page = $self->{pdf}->openpage($i);
+    my $txtobj = $page->text;
+    my $txt;
+    my $font;
+    if ($type eq 'roman') {
+      require Text::Roman;
+      $font = $self->{pdf}->corefont("Times-roman");
+      $txt = Text::Roman::int2roman($i). " of " .
+             Text::Roman::int2roman($total);
+    } else {
+      $font = $self->{pdf}->corefont("Helvetica");
+      $txt = "Page $i of $total";
+    }
+    my $size = 10;
+    $txtobj->font($font, $size);
+    $txtobj->translate($self->{Xmargin}, 8);
+    $txtobj->text($txt);
+    $size = $self->getStringWidth($DATE);
+    $txtobj->translate($self->{PageWidth} - $self->{Xmargin} - $size, 8);
+    $txtobj->text($DATE);
+  }
+}
+
+### END PRIVATE SUBS ##########################################################
+
+=head1 AUTHOR
+
+Andrew Orr
+
+=cut

Added: packages/libpdf-report-perl/branches/upstream/current/examples/barcode
===================================================================
--- packages/libpdf-report-perl/branches/upstream/current/examples/barcode	2005-01-27 16:09:40 UTC (rev 678)
+++ packages/libpdf-report-perl/branches/upstream/current/examples/barcode	2005-01-27 16:14:41 UTC (rev 679)
@@ -0,0 +1,50 @@
+require "../Report.pm";
+
+my $pdf = new PDF::Report(
+                          PageSize => letter,
+                          PageOrientation => portrait,
+                          undef => undef
+                         );
+
+$pdf->newpage(1);
+$pdf->setFont('Helvetica-bold');
+$pdf->setSize(16);
+my ($width, $height) = $pdf->getPageDimensions();
+
+$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 @codes = qw(010203045678909 010203045678909 010203045678909 
+               384318530034967067 384318530034967067 384318530034967067 
+               384318530034967067 384318530034967067 384318530034967067);
+
+$pdf->setFont('Helvetica');
+$pdf->setSize(10);
+
+my $next_line = 120;
+
+foreach my $nbr (0 .. $#types) {
+  if ($y < 50) {
+   $pdf->newpage(1);
+   $y = $height - 80;
+  }
+  if (($types[$nbr] eq '3of9ext') or ($types[$nbr] eq '3of9extchk')) {
+    $ext = 90506;
+  } 
+  $pdf->centerString(0, $width, $y+50, $types[$nbr]);
+  $pdf->drawBarcode($x, $y, 1, 1, 
+                   $types[$nbr], $codes[$nbr], $ext, 
+                   10, 10, 50, 10, ' ', undef, 8, undef);
+  $y-=$next_line;
+  $ext = "";
+}
+
+open(PDF, "> $0.pdf") or die "Error opening $0.pdf: $!\n";
+print PDF $pdf->Finish();
+close(PDF);
+
+exit;

Added: packages/libpdf-report-perl/branches/upstream/current/examples/footer
===================================================================
--- packages/libpdf-report-perl/branches/upstream/current/examples/footer	2005-01-27 16:09:40 UTC (rev 678)
+++ packages/libpdf-report-perl/branches/upstream/current/examples/footer	2005-01-27 16:14:41 UTC (rev 679)
@@ -0,0 +1,34 @@
+require "../Report.pm";
+
+my $pdf = new PDF::Report(
+                          PageSize => LETTER, 
+                          PageOrientation => portrait,
+                          undef => undef
+                         );
+
+$pdf->setFont('Helvetica');
+$pdf->setSize(12);
+my ($width, $height) = $pdf->getPageDimensions();
+my $y1 = $height - 30;
+my $x1 = 30;
+
+for (1 .. 4) {
+  $pdf->newpage();
+}
+
+open(PDF, "> $0.pdf") or die "Error opening $0.pdf: $!\n";
+print PDF $pdf->Finish(\&footer);
+close(PDF);
+
+exit;
+
+sub footer {
+  my $pages = $pdf->pages;
+
+  $pdf->setFont("Times-roman");
+  $pdf->setSize(8);
+  for (1 .. $pages) {
+    $pdf->openpage($_);
+    $pdf->centerString($x1, $width-30, 10, "$_ out of $pages pages");
+  }
+}

Added: packages/libpdf-report-perl/branches/upstream/current/examples/openpdf
===================================================================
--- packages/libpdf-report-perl/branches/upstream/current/examples/openpdf	2005-01-27 16:09:40 UTC (rev 678)
+++ packages/libpdf-report-perl/branches/upstream/current/examples/openpdf	2005-01-27 16:14:41 UTC (rev 679)
@@ -0,0 +1,24 @@
+require "../Report.pm";
+
+my $file = $ARGV[0];
+print "Pass me a PDF file." if ! -e $file;
+
+my $pdf = new PDF::Report(
+                          File => $file,
+                          undef => undef
+                         );
+
+$pdf->openpage(1);
+
+$pdf->setFont('Helvetica');
+$pdf->setSize(12);
+
+my ($pageW, $pageH) = $pdf->getPageDimensions();
+$pdf->shadeRect(30, $pageH-5, 200, $pageH-30, 'grey');
+$pdf->addRawText("Document opened successfully", 32, $pageH-22, 'red');
+
+open(PDF, "> $0.pdf") or die "Error opening $0.pdf: $!\n";
+print PDF $pdf->Finish();
+close(PDF);
+ 
+exit;

Added: packages/libpdf-report-perl/branches/upstream/current/examples/paragraph
===================================================================
--- packages/libpdf-report-perl/branches/upstream/current/examples/paragraph	2005-01-27 16:09:40 UTC (rev 678)
+++ packages/libpdf-report-perl/branches/upstream/current/examples/paragraph	2005-01-27 16:14:41 UTC (rev 679)
@@ -0,0 +1,39 @@
+require "../Report.pm";
+
+my $pdf = new PDF::Report(
+                          PageSize => letter,
+                          PageOrientation => portrait,
+                          undef => undef
+                         );
+
+$pdf->newpage(1);
+$pdf->setFont('Helvetica-bold');
+$pdf->setSize(16);
+my ($width, $height) = $pdf->getPageDimensions();
+
+$pdf->centerString(0, $width, $height-40, "Paragraph");
+
+$pdf->setFont('Helvetica');
+$pdf->setSize(10);
+
+my $text1= 
+"A doctor, an architect, and a computer scientist were arguing about whose profession was the oldest.  In the course of their arguments, they got all the way back to the Garden of Eden, whereupon the doctor said, \"The medical profession is clearly the oldest, because Eve was made from Adam's rib, as the story goes, and that was a simply incredible surgical feat.\"";
+
+my $text2=
+        "The architect did not agree.  He said, \"But if you look at the Garden 
+itself, in the beginning there was chaos and void, and out of that the Garden 
+and the world were created.  So God must have been an architect.\"";
+
+my $text3=
+        "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);
+
+open(PDF, "> $0.pdf") or die "Error opening $0.pdf: $!\n";
+print PDF $pdf->Finish();
+close(PDF);
+ 
+exit;

Added: packages/libpdf-report-perl/branches/upstream/current/examples/piegraph
===================================================================
--- packages/libpdf-report-perl/branches/upstream/current/examples/piegraph	2005-01-27 16:09:40 UTC (rev 678)
+++ packages/libpdf-report-perl/branches/upstream/current/examples/piegraph	2005-01-27 16:14:41 UTC (rev 679)
@@ -0,0 +1,27 @@
+require "../Report.pm";
+
+my $pdf = new PDF::Report(
+                          PageSize => letter,
+                          PageOrientation => portrait,
+                          undef => undef
+                         );
+
+$pdf->newpage(1);
+$pdf->setFont('Helvetica-bold');
+$pdf->setSize(16);
+my ($width, $height) = $pdf->getPageDimensions();
+
+$pdf->centerString(0, $width, $height-40, "Big Pie Graph");
+
+my @data = qw(2 4 3 2 3 5 2 4 2 3 4 5 3 4 3 5 4 2 4 3 4);
+my @labels;
+for (0 .. $#data) {
+  push(@labels, "label" . $_);  
+} 
+$pdf->drawPieGraph($width/2, $height-200, 100, \@data, \@labels);
+
+open(PDF, "> $0.pdf") or die "Error opening $0.pdf: $!\n";
+print PDF $pdf->Finish();
+close(PDF);
+ 
+exit;

Added: packages/libpdf-report-perl/branches/upstream/current/examples/rotate
===================================================================
--- packages/libpdf-report-perl/branches/upstream/current/examples/rotate	2005-01-27 16:09:40 UTC (rev 678)
+++ packages/libpdf-report-perl/branches/upstream/current/examples/rotate	2005-01-27 16:14:41 UTC (rev 679)
@@ -0,0 +1,25 @@
+require "../Report.pm";
+
+my $pdf = new PDF::Report(
+                          PageSize => LETTER, 
+                          PageOrientation => portrait,
+                          undef => undef
+                         );
+
+$pdf->setFont('Helvetica');
+$pdf->setSize(12);
+my ($width, $height) = $pdf->getPageDimensions();
+my $y1 = $height - 30;
+my $x1 = 30;
+
+$pdf->newpage();
+
+# Add some text with rotate, and let's throw in some color for the fun of it
+$pdf->addRawText("This is some text of a different color, rotated.", 
+                 $x1+200, $y1-300, 'green', '', '', 315);
+
+open(PDF, "> $0.pdf") or die "Error opening $0.pdf: $!\n";
+print PDF $pdf->Finish;
+close(PDF);
+
+exit;

Added: packages/libpdf-report-perl/branches/upstream/current/test.pl
===================================================================
--- packages/libpdf-report-perl/branches/upstream/current/test.pl	2005-01-27 16:09:40 UTC (rev 678)
+++ packages/libpdf-report-perl/branches/upstream/current/test.pl	2005-01-27 16:14:41 UTC (rev 679)
@@ -0,0 +1,19 @@
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl test.pl'
+
+#########################
+
+# change 'tests => 1' to 'tests => last_test_to_print';
+
+use Test;
+BEGIN { plan tests => 1 };
+use PDF::Report;
+ok(1); # If we made it this far, we're ok.
+
+#########################
+
+# Insert your test code below, the Test module is use()ed here so read
+# its man page ( perldoc Test ) for help writing this test script.
+
+
+




More information about the Pkg-perl-cvs-commits mailing list