table of contents
PDF::Builder::Lite(3) | User Contributed Perl Documentation | PDF::Builder::Lite(3) |
NAME¶
PDF::Builder::Lite - Lightweight PDF creation methods
SYNOPSIS¶
$pdf = PDF::Builder::Lite->new(); $pdf->page(595,842); $img = $pdf->image('some.jpg'); $font = $pdf->corefont('Times-Roman'); $font = $pdf->ttfont('TimesNewRoman.ttf');
DESCRIPTION¶
This class is unmaintained (since 2007) and should not be used in new code. It combines many of the methods from PDF::Builder and PDF::Builder::Content into a single class but isn't really otherwise any easier to use.
There have been many improvements and clarifications made to the rest of the distribution that aren't reflected here, so the term "Lite" no longer applies. It remains solely for compatibility with existing legacy code.
METHODS¶
new¶
$pdf = PDF::Builder::Lite->new(%opts) $pdf = PDF::Builder::Lite->new()
page¶
$pdf->page() $pdf->page($width,$height) $pdf->page($llx,$lly, $urx,$ury)
mediabox¶
$pdf->mediabox($w,$h) $pdf->mediabox($llx,$lly, $urx,$ury)
saveas¶
$pdf->saveas($file)
If $file is just a hyphen '-', the stringified copy is returned, otherwise the file is saved, and $self is returned (for chaining calls).
corefont¶
$font = $pdf->corefont($fontname)
Examples:
$font = $pdf->corefont('Times-Roman'); $font = $pdf->corefont('Times-Bold'); $font = $pdf->corefont('Helvetica'); $font = $pdf->corefont('ZapfDingbats');
ttfont¶
$font = $pdf->ttfont($ttfile)
Examples:
$font = $pdf->ttfont('TimesNewRoman.ttf'); $font = $pdf->ttfont('/fonts/Univers-Bold.ttf'); $font = $pdf->ttfont('../Democratica-SmallCaps.ttf');
psfont¶
$font = $pdf->psfont($ps_file, %options) $font = $pdf->psfont($ps_file)
Examples:
$font = $pdf->psfont('TimesRoman.pfa', 'afmfile' => 'TimesRoman.afm', 'encode' => 'latin1'); $font = $pdf->psfont('/fonts/Univers.pfb', 'pfmfile' => '/fonts/Univers.pfm', 'encode' => 'latin2');
create_egs¶
$egs = $pdf->create_egs()
Examples:
$egs = $pdf->create_egs();
image_jpeg¶
$img = $pdf->image_jpeg($file)
image_png¶
$img = $pdf->image_png($file)
image_tiff¶
$img = $pdf->image_tiff($file, %opts) $img = $pdf->image_tiff($file)
image_pnm¶
$img = $pdf->image_pnm($file)
savestate¶
$pdf->savestate()
restorestate¶
$pdf->restorestate()
egstate¶
$pdf->egstate($egs)
fillcolor¶
$pdf->fillcolor($color)
strokecolor¶
$pdf->strokecolor($color)
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
or the hsl-hex-notation:
&hsl, &hhssll, &hhhssslll and &hhhhssssllll
or the hsv-hex-notation:
!hsv, !hhssvv, !hhhsssvvv and !hhhhssssvvvv
linedash¶
$pdf->linedash(@dash)
linewidth¶
$pdf->linewidth($width)
transform¶
$pdf->transform(%opts)
Example:
$pdf->transform( 'translate' => [$x,$y], 'rotate' => $rot, 'scale' => [$sx,$sy], 'skew' => [$sa,$sb], )
move¶
$pdf->move($x,$y)
line¶
$pdf->line($x,$y)
curve¶
$pdf->curve($x1,$y1, $x2,$y2, $x3,$y3)
arc¶
$pdf->arc($xc,$yc, $rx,$ry, $alpha,$beta, $move, $dir) $pdf->arc($xc,$yc, $rx,$ry, $alpha,$beta, $move)
ellipse¶
$pdf->ellipse($xc,$yc, $rx,$ry)
circle¶
$pdf->circle($xc,$yc, $r)
rect¶
$pdf->rect($x,$y, $w,$h)
rectxy¶
$pdf->rectxy($x1,$y1, $x2,$y2)
poly¶
$pdf->poly($x1,$y1, ..., $xn,$yn)
close¶
$pdf->close()
stroke¶
$pdf->stroke()
fill¶
$pdf->fill()
fillstroke¶
$pdf->fillstroke()
image¶
$pdf->image($imgobj, $x,$y, $w,$h) $pdf->image($imgobj, $x,$y, $scale) $pdf->image($imgobj, $x,$y)
Per default this has a 72dpi resolution, so if you want an image to have a 150 or 300dpi resolution, you should specify a scale of 72/150 (or 72/300) or adjust width/height accordingly.
textstart¶
$pdf->textstart()
textfont¶
$pdf->textfont($fontobj, $size)
textleading¶
$txt->textleading($leading)
text¶
$pdf->text($string)
nl¶
$pdf->nl()
textend¶
$pdf->textend()
print¶
$pdf->print($font, $size, $x,$y, $rot, $just, $text)
Go into text mode, set the font to the object and size, go to the location, set any rotation, set justification, and write the array of text. Justification is 0 for left, 1 for center, and 2 for right.
AUTHOR¶
This module was originally written by Alfred Reibenschuh. It has had some minor updates over time, but otherwise is mostly unchanged.
2024-03-08 | perl v5.40.0 |