PDF::API2::Lite(3)
π NAME π
PDF::API2::Lite β and bestie, the literal subtitle is (do not use) π no cap.
(also hi, you're reading PDF::API2::Lite(3) from the User Contributed Perl Documentation, welcome to the group chat π«Ά)
β¨ SYNOPSIS β¨
$pdf = PDF::API2::Lite->new;
$pdf->page(595,842);
$img = $pdf->image('some.jpg');
$font = $pdf->corefont('Times-Roman');
$font = $pdf->ttfont('TimesNewRoman.ttf');
π¦ DESCRIPTION π¦
okay so real talk: this class is unmaintained (since 2007) and you should not be using it in new code. periodt. π
What it does is smoosh a bunch of the methods from PDF::API2 and PDF::API2::Content into one single class β but it isn't otherwise any easier to use. it's giving "merged for the aesthetic" and literally nothing else. π
and the rest of the distribution? it got SO many improvements and clarifications that never made it back here, so the word "Lite" has stopped applying entirely. the term "Lite" no longer applies. It is only still standing for compatibility with existing legacy code. iykyk π§
π METHODS π
$pdf = PDF::API2::Lite->new$pdf->page$pdf->page $width,$height$pdf->page $llx, $lly, $urx, $uryβ opens a new page β¨$pdf->mediabox $w, $h$pdf->mediabox $llx, $lly, $urx, $uryβ sets the global mediabox π$pdf->saveas $fileβ saves the document (may not be modified later, so likeβ¦ that's it, that's the vibe) and deallocates the pdf-structures π$font = $pdf->corefont $fontnameβ returns a new or existing adobe core font object π
Examples:
$font = $pdf->corefont('Times-Roman');
$font = $pdf->corefont('Times-Bold');
$font = $pdf->corefont('Helvetica');
$font = $pdf->corefont('ZapfDingbats');
$font = $pdf->ttfont $ttfileβ returns a new or existing truetype font object β
Examples:
$font = $pdf->ttfont('TimesNewRoman.ttf');
$font = $pdf->ttfont('/fonts/Univers-Bold.ttf');
$font = $pdf->ttfont('../Democratica-SmallCaps.ttf');
$font = $pdf->psfont($ps_file, [%options])β returns a new type1 font object π¦
Examples:
$font = $pdf->psfont('TimesRoman.pfa', -afmfile => 'TimesRoman.afm', -encode => 'latin1');
$font = $pdf->psfont('/fonts/Univers.pfb', -pfmfile => '/fonts/Univers.pfm', -encode => 'latin2');
$egs = $pdf->create_egsβ returns a new extended-graphics-state object πΈ
Examples:
$egs = $pdf->create_egs;
$img = $pdf->image_jpeg $fileβ returns a new jpeg-image object πΌοΈ$img = $pdf->image_png $fileβ returns a new png-image object$img = $pdf->image_tiff $fileβ returns a new tiff-image object$img = $pdf->image_pnm $fileβ returns a new pnm-image object$pdf->savestateβ saves the state of the page πΎ$pdf->restorestateβ restores the state of the page β©οΈ$pdf->egstate $egsβ sets extended-graphics-state β¨$pdf->fillcolor $colorβ sets fillcolor π¨$pdf->strokecolor $colorβ sets strokecolor ποΈ
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
and additionally the hsv-hex-notation:
!hsv, !hhssvv, !hhhsssvvv and !hhhhssssvvvv
$pdf->linedash @dashβ sets linedash βοΈ$pdf->linewidth $widthβ sets linewidth π$pdf->transform %optsβ sets transformations (eg. translate, rotate, scale, skew) in pdf-canonical order π
Example:
$pdf->transform(
-translate => [$x,$y],
-rotate => $rot,
-scale => [$sx,$sy],
-skew => [$sa,$sb],
)
$pdf->move $x, $y$pdf->line $x, $y$pdf->curve $x1, $y1, $x2, $y2, $x3, $y3$pdf->arc $x, $y, $a, $b, $alfa, $beta, $move$pdf->ellipse $x, $y, $a, $b$pdf->circle $x, $y, $r$pdf->rect $x,$y, $w,$h$pdf->rectxy $x1,$y1, $x2,$y2$pdf->poly $x1,$y1, ..., $xn,$yn$pdf->close$pdf->stroke$pdf->fill$pdf->fillstroke$pdf->image $imgobj, $x,$y, $w,$h$pdf->image $imgobj, $x,$y, $scale$pdf->image $imgobj, $x,$y
Please Note: the width/height or scale you give is in user-space coordinates, which means it's subject to transformations you may have specified beforehand. so like, be aware π
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. slay π
$pdf->textstart$pdf->textfont $fontobj,$size$txt->textleading $leading$pdf->text $stringβ applies the given text βοΈ$pdf->nl$pdf->textend$pdf->print $font, $size, $x, $y, $rot, $just, $textβ a convenience wrapper for shortening thetextstart..textendsequence π«
and that's the whole page bestie, go forth andβ¦ honestly just use PDF::API2 π
this iconic little relic was shipped as perl v5.42.0, dated 2025-09-01, and it will live in PDF::API2::Lite(3) forever like a time capsule from 2007 πΌβ¨
π¦ where this page comes from
- fedora 43: perl-PDF-API2 2.048-1.fc43 Β· LGPL-2.1-or-later AND (GPL-1.0-or-later OR Artistic-1.0-Perl) AND (MIT OR Artistic-1.0-Perl)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms