PDF::Report
NAME
PDF::Report - A wrapper written for PDF::API2
SYNOPSIS
use PDF::Report;
my $pdf = new PDF::Report(%opts);
METHODS
- 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");
%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();
-
Creates a new blank page. Pass a 1 to toggle page numbering.
- ($pagewidth, $pageheight) = $pdf->getPageDimensions();
-
Returns the width and height of the page according to what page size chosen in "new".
- $pdf->addRawText($text, $x, $y);
-
Add $text at position $x, $y
- 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; }
- $pdf->setAddTextPos($hPos, $vPos);
-
Set the position on the page. Used by the addText function.
- ($hPos, $vPos) = $pdf->getAddTextPos();
-
Return the (x, y) value of the text position.
- $pdf->setAlign($align);
-
Set the justification of the text. Used by the addText function.
- $align = $pdf->getAlign();
-
Returns the text justification.
- $newtext = $pdf->wrapText($text, $width);
-
This is a helper function called by addText, which can be called by itself. wrapText() wraps $text within $width.
- $pdf->addText($text, $hPos, $textWidth);
-
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.
- $pdf->addParagragh($text, $hPos, $vPos, $width, $indent);
-
Add $text at ($hPos, $vPos) within $width with $indent. $indent is the number of spaces at the beginning of the first line.
- $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!
- $pdf->getStringWidth($String);
-
Returns the width of $String according to the current font and fontsize being used.
- $pdf->addImg($file, $x, $y);
-
Add image $file to the current page at position ($x, $y).
- $pdf->addImg($file, $x, $y);
-
Add image $file to the current page at position ($x, $y) scaled to $scale.
- $pdf->setGfxLineWidth($width);
-
Set the line width drawn on the page.
- $width = $pdf->getGfxLineWidth();
-
Returns the current line width.
- $pdf->drawLine($x1, $y1, $x2, $y2);
-
Draw a line on the current page starting at ($x1, $y1) and ending at ($x2, $y2).
- $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).
- $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).
- 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
- $pdf->setFont($font);
-
Creates a new font object of type $font to be used in the page.
- $fontname = $pdf->getFont();
-
Returns the font name currently being used.
- $pdf->setSize($size);
-
Sets the fontsize to $size. Called before setFont().
- $fontsize = $pdf->getSize();
-
Returns the font size currently being used.
- $pdf->setInfo(%infohash);
-
Sets the info structure of the document. Valid keys for %infohash:
- print $pdf->Finish();
-
Returns the PDF document as text.
- Example:
-
# Hand the document to the web browser print "Content-type: application/pdf\n\n"; print $pdf->Finish();
AUTHOR
Andrew Orr
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 79:
'=item' outside of any '=over'
- Around line 781:
You forgot a '=back' before '=head1'