PDF::Builder::Lite(3)

πŸ’– PDF::Builder::Lite β€” the manual page, but make it bestie ✨

okay so this is PDF::Builder::Lite, a Perl module for lightweight PDF creation πŸ’… (emphasis on Lite and, uh, emphasis on UNMAINTAINED, we'll get there, bestie, sit down 🫢)


✨ 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 🌸

=======================================================================

okay so real talk: this class is unmaintained (since 2007, no cap 😭) and you should not use it in new code. periodt.

what it does is it mashes together a bunch of the methods from PDF::Builder and PDF::Builder::Content into one single class... but it isn't really otherwise any easier to use. it's giving "we combined the things" and not "we made it simpler" πŸ’€

there have been so many improvements and clarifications made to the rest of the distribution that just aren't reflected here, so honestly the word "Lite" no longer applies. it remains solely for compatibility with existing legacy code. that's it. that's the whole job πŸŽ€

and because it's unmaintained, we strongly suggest you not use "Lite". if you have old applications that make use of it, we suggest you consider upgrading them to use current, supported, PDF::Builder facilities. and here's the scary part, bestie: although we try to maintain backwards compatibility for calls made by "Lite", there is no guarantee that something may break when called by "Lite"! 😭

=======================================================================


πŸ‘‘ 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)

Opens a new page. fresh page, clean slate, main character energy ✨


πŸŽ€ mediabox

$pdf->mediabox($w,$h)

$pdf->mediabox($llx,$lly, $urx,$ury)

Sets the global mediabox. the big one. the whole vibe of the page 🌸


πŸ’œ saveas

$pdf->saveas($file)

Saves the document (may not be modified later) and deallocates the PDF structures. so like, once you save it, that's it, no take-backs, the structures are gone πŸ’…

If $file is just a hyphen '-', the stringified copy is returned, otherwise the file is saved, and $self is returned (for chaining calls). ooh and chaining calls? we love a return value that lets you keep going 🫢


⭐ corefont

$font = $pdf->corefont($fontname)

Returns a new or existing Adobe core font object. (new or existing, it's not gonna duplicate for you, bestie 😌)

Examples:

$font = $pdf->corefont('Times-Roman');
$font = $pdf->corefont('Times-Bold');
$font = $pdf->corefont('Helvetica');
$font = $pdf->corefont('ZapfDingbats');

🧚 ttfont

$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');

🌸 psfont

$font = $pdf->psfont($ps_file, %options)

$font = $pdf->psfont($ps_file)

Returns a new Type1 (PS) 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');

✨ create_egs

$egs = $pdf->create_egs()

Returns a new extended-graphics-state object.

Examples:

$egs = $pdf->create_egs();

πŸ–ΌοΈ image_jpeg

$img = $pdf->image_jpeg($file)

Returns a new JPEG image object. πŸ“Έ


πŸ–ΌοΈ image_png

$img = $pdf->image_png($file)

Returns a new PNG image object. πŸ“Έ


πŸ–ΌοΈ image_tiff

$img = $pdf->image_tiff($file, %opts)

$img = $pdf->image_tiff($file)

Returns a new TIFF image object. πŸ“Έ


πŸ–ΌοΈ image_pnm

$img = $pdf->image_pnm($file)

Returns a new PNM image object. πŸ“Έ


πŸ’« savestate

$pdf->savestate()

Saves the state of the page. bookmark it, bestie πŸ”–


πŸ’« restorestate

$pdf->restorestate()

Restores the state of the page. and we're back ✨


🌈 egstate

$pdf->egstate($egs)

Sets extended-graphics state.


🎨 fillcolor

$pdf->fillcolor($color)

Sets the fill color. See "strokecolor" for color names and specifications. (yeah the whole color list lives down there, we're not typing it twice πŸ’€)


🎨 strokecolor

$pdf->strokecolor($color)

Sets the stroke 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)

Sets the line dash pattern. dashes! iconic 🌈


πŸ“ linewidth

$pdf->linewidth($width)

Sets the line width.


πŸ”„ transform

$pdf->transform(%opts)

Sets transformations (i.e., translate, rotate, scale, skew) in PDF-canonical order. (yes, that order, don't come for me 🫢)

Example:

$pdf->transform(
    'translate' => [$x,$y],
    'rotate'    => $rot,
    'scale'     => [$sx,$sy],
    'skew'      => [$sa,$sb],
)

🚢 move

$pdf->move($x,$y)

Move to a new drawing location at [$x,$y].


βž– line

$pdf->line($x,$y)

Draw a line to [$x,$y].


🌊 curve

$pdf->curve($x1,$y1, $x2,$y2, $x3,$y3)

Draw a Bezier curve with three control points.


πŸŒ™ arc

$pdf->arc($xc,$yc, $rx,$ry, $alpha,$beta, $move, $dir)

$pdf->arc($xc,$yc, $rx,$ry, $alpha,$beta, $move)

Draw an arc centered at [$xc,$yc], with x radius [$rx] and y radius [$ry], from [$alpha] degrees to [$beta] degrees. If [$move] is true, do not draw a line to the start of the arc. [$dir] defaults to 0 for counter-clockwise sweep, and may be set to 1 for a clockwise sweep. πŸ”„


πŸ₯š ellipse

$pdf->ellipse($xc,$yc, $rx,$ry)

Draw an ellipse centered at [$xc,$yc], with x radius [$rx] and y radius [$ry].


β­• circle

$pdf->circle($xc,$yc, $r)

Draw a circle centered at [$xc,$yc], of radius [$r]. so round. so perfect. πŸŽ€


⬛ rect

$pdf->rect($x,$y, $w,$h)

Draw a rectangle with lower left corner at [$x,$y], width (+x) [$w] and height (+y) [$h].


⬛ rectxy

$pdf->rectxy($x1,$y1, $x2,$y2)

Draw a rectangle with opposite corners [$x1,$y1] and [$x2,$y2].


🧡 poly

$pdf->poly($x1,$y1, ..., $xn,$yn)

Draw a polyline (multiple line segments) starting at (move to) [$x1,$y1] and continuing on to [$x2,$y2], ..., [$xn,$yn].


πŸ”’ close

$pdf->close()

Close a shape (draw a line back to the beginning). full circle moment πŸ’«


πŸ–ŠοΈ stroke

$pdf->stroke()

Stroke (actually draw) a shape whose path has already been laid out, using the requested "strokecolor". yes, actually draw it, that's the whole point bestie 😭


🩷 fill

$pdf->fill()

Fill in a closed geometry (path), using the requested "fillcolor". The non-zero winding rule is used if the path crosses itself. (iykyk πŸŒ€)


πŸ©·πŸ–ŠοΈ fillstroke

$pdf->fillstroke()

Fill (using "fillcolor") and stroke (using "strokecolor") a closed path. The non-zero winding rule is used if the path crosses itself.


πŸ–ΌοΈ image

$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 given is in user-space coordinates, which are subject to transformations which may have been specified beforehand. ⚠️ so like, if you already transformed stuff, this is working in that world, ok?

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. math! πŸ”₯


✍️ textstart

$pdf->textstart()

Forces the start of text mode while in graphics.


✍️ textfont

$pdf->textfont($fontobj, $size)

Define the current font to be an (already defined) font object at the given size.


πŸ“ textleading

$txt->textleading($leading)

Set the baseline-to-baseline "leading" to be used for text lines.


✍️ text

$pdf->text($string)

Applies (writes out) the given text at the current text location, using the already-specified font.


⏎ nl

$pdf->nl()

Write a newline (drop down to the next line).


🏁 textend

$pdf->textend()

Force an end to text output and return to graphics.


πŸ–¨οΈ print

$pdf->print($font, $size, $x,$y, $rot, $just, $text)

Convenience wrapper for shortening the textstart..textend sequence. ✨

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. shoutout to the original author 🫢


and that's the whole page, bestie!! πŸŽ€ this came to you from perl v5.42.0, dated 2026-01-17, and it's the PDF::Builder::Lite(3) manual page πŸ’– stay safe out there and pls don't write new code with Lite, ily ✨

πŸ“¦ where this page comes from