PDF::Report - A wrapper written for PDF::API2
use PDF::Report; my $pdf = new PDF::Report(%opts);
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'
Creates a new blank page. Pass $nopage = 1 to toggle page numbering.
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 $text at position $x, $y with $color, $underline, $indent and/or $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.
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 $text within $width.
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.
Add $text at ($hPos, $vPos) within $width and $height, with $indent. $indent is the number of spaces at the beginning of the first line.
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!
Returns the width of $String according to the current font and fontsize being used.
Add image $file to the current page at position ($x, $y).
Add image $file to the current page at position ($x, $y) scaled to $scale.
Set the line width drawn on the page.
Returns the current line width.
Draw a line on the current page starting at ($x1, $y1) and ending at ($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).
Shade a rectangle with $color. Top left corner is ($x1, $y1) and the bottom right corner is ($x2, $y2).
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 $rLabels is passed. $x and $y are the coordinates for the center of the pie and $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. $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 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 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.
Creates a new font object of type $font to be used in the page.
Returns the font name currently being used.
Sets the fontsize to $size. Called before setFont().
Returns the font size currently being used.
Sets the info structure of the document. Valid keys for %infohash: Creator, Producer, CreationDate, Title, Subject, Author, etc.
Gets meta-data from the info structure of the document. Valid keys for %infohash: Creator, Producer, CreationDate, Title, Subject, Author, etc.
Saves the document to a file.
# 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.
# Hand the document to the web browser print "Content-type: application/pdf\n\n"; print $pdf->Finish();
Andrew Orr
To install PDF::Report, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PDF::Report
CPAN shell
perl -MCPAN -e shell install PDF::Report
For more information on module installation, please visit the detailed CPAN module installation guide.