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 the textstart..textend sequence πŸ’«

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