man PDF::Report () -

PDF::Report

NAME

PDF::Report - A wrapper written for PDF::API2

SYNOPSIS

        use PDF::Report;

        my $pdf = new PDF::Report(%opts);

METHODS

        Creates a new pdf report object.  
        If no %opts are specified the module 
        will use the factory defaults.

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'
$pdf->newpage($nopage);
Creates a new blank page. Pass CW$nopage = 1 to toggle page numbering.
$pdf->openpage($index);
If no index is specified, this will open the last page of the document. Returns the width and height of the page according to what page size chosen in new. Add CW$text at position CW$x, CW$y with CW$color, CW$underline, CW$indent and/or CW$rotate. 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. 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;
    }
Set the position on the page. Used by the addText function. Return the (x, y) value of the text position.
$pdf->setAlign($align);
Set the justification of the text. Used by the addText function. Returns the text justification. This is a helper function called by addText, which can be called by itself. wrapText() wraps CW$text within CW$width. Takes CW$text and prints it to the current page at CW$hPos. You may just want to pass this function CW$text if the text is pre-wrapped and setAddTextPos has been called previously. Pass a CW$hPos to change the position the text will be printed on the page. Pass a CW$textWidth and addText will wrap the text for you. CW$textHeight controls the row height. Add CW$text at ($hPos, CW$vPos) within CW$width and CW$height, with CW$indent. CW$indent is the number of spaces at the beginning of the first line. Centers CW$text between points CW$a and CW$b at position CW$yPos. Be careful how much text you try to jam between those points, this function shrinks the text till it fits!
$pdf->getStringWidth($String);
Returns the width of CW$String according to the current font and fontsize being used. Add image CW$file to the current page at position ($x, CW$y). Add image CW$file to the current page at position ($x, CW$y) scaled to CW$scale.
$pdf->setGfxLineWidth($width);
Set the line width drawn on the page. Returns the current line width. Draw a line on the current page starting at ($x1, CW$y1) and ending at ($x2, CW$y2). Draw a rectangle on the current page. Top left corner is represented by ($x1, CW$y1) and the bottom right corner is ($x2, CW$y2). Shade a rectangle with CW$color. Top left corner is ($x1, CW$y1) and the bottom right corner is ($x2, CW$y2).
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
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 CW$rLabels is passed. CW$x and CW$y are the coordinates for the center of the pie and CW$size is the radius. 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. CW$x and CW$y represent the center of the barcode's position on the document. CW$scale is the size of the entire barcode 1 being 1:1, which is all you'll need most likely. CW$type is the type of barcode which can be codabar, 2of5int, 3of9, code128, or ean13. CW$code is the alpha-numeric code which the barcode will represent. CW$extn is the extension to the CW$code, where applicable. CW$umzn is the upper mending zone and CW$lmzn is the lower mending zone. CW$zone is the the zone or height of the bars. CW$quzn is the quiet zone or the space between the frame and the barcode. CW$spcr is what to put between each number/character in the text. CW$ofwt is the overflow width. CW$fnsz is the fontsize used for the text. CW$text is optional text beneathe the barcode.
$pdf->setFont($font);
Creates a new font object of type CW$font to be used in the page. Returns the font name currently being used.
$pdf->setSize($size);
Sets the fontsize to CW$size. Called before setFont(). Returns the font size currently being used.
$pdf->setInfo(%infohash);
Sets the info structure of the document. Valid keys for CW%infohash: Creator, Producer, CreationDate, Title, Subject, Author, etc.
$pdf->saveAs($fileName);
Saves the document to a file.
Example:
       # Save the document as "file.pdf"
        my $fileName = "file.pdf";
       $pdf->saveAs($fileName);
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.
Example:
        # Hand the document to the web browser
        print "Content-type: application/pdf\n\n";
        print $pdf->Finish();

AUTHOR

Andrew Orr