DOKK / manpages / debian 11 / libpdf-builder-perl / PDF::Builder::Lite.3pm.en
PDF::Builder::Lite(3pm) User Contributed Perl Documentation PDF::Builder::Lite(3pm)

PDF::Builder::Lite - Lightweight PDF creation methods

    $pdf = PDF::Builder::Lite->new();
    $pdf->page(595,842);
    $img = $pdf->image('some.jpg');
    $font = $pdf->corefont('Times-Roman');
    $font = $pdf->ttfont('TimesNewRoman.ttf');

$pdf = PDF::Builder::Lite->new(%opts)
$pdf = PDF::Builder::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) and deallocates the PDF structures.

If $file is just a hyphen '-', the stringified copy is returned, otherwise the file is saved, and $self is returned (for chaining calls).

$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)
$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');
    
$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, %opts)
$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 the fill color. See "strokecolor" for color names and specifications.
$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
    
$pdf->linedash(@dash)
Sets the line dash pattern.
$pdf->linewidth($width)
Sets the line width.
$pdf->transform(%opts)
Sets transformations (i.e., 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)
Move to a new drawing location at C[$x,$y].
$pdf->line($x,$y)
Draw a line to C[$x,$y].
$pdf->curve($x1,$y1, $x2,$y2, $x3,$y3)
Draw a Bezier curve with three control points.
$pdf->arc($xc,$yc, $rx,$ry, $alpha,$beta, $move, $dir)
$pdf->arc($xc,$yc, $rx,$ry, $alpha,$beta, $move)
Draw an arc centered at C[$xc,$yc], with x radius C[$rx] and y radius C[$ry], from C[$alpha] degrees to C[$beta] degrees. If C[$move] is true, do not draw a line to the start of the arc. C[$dir] defaults to 0 for counter-clockwise sweep, and may be set to 1 for a clockwise sweep.
$pdf->ellipse($xc,$yc, $rx,$ry)
Draw an ellipse centered at C[$xc,$yc], with x radius C[$rx] and y radius C[$ry].
$pdf->circle($xc,$yc, $r)
Draw a circle centered at C[$xc,$yc], of radius C[$r].
$pdf->rect($x,$y, $w,$h)
Draw a rectangle with lower left corner at C[$x,$y], width (+x) C[$w] and height (+y) C[$h].
$pdf->rectxy($x1,$y1, $x2,$y2)
Draw a rectangle with opposite corners C[$x1,$y1] and C[$x2,$y2].
$pdf->poly($x1,$y1, ..., $xn,$yn)
Draw a polyline (multiple line segments) starting at (move to) C[$x1,$y1] and continuing on to C[$x2,$y2], ..., C[$xn,$yn].
$pdf->close()
Close a shape (draw a line back to the beginning).
$pdf->stroke()
Stroke (actually draw) a shape whose path has already been laid out, using the requested "strokecolor".
$pdf->fill()
Fill in a closed geometry (path), using the requested "fillcolor". The non-zero winding rule is used if the path crosses itself.
$pdf->fillstroke()
Fill (using "fillcolor") and stroke (using "strokecolor") a closed path. The non-zero winding rule is used if the path crosses itself.
$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.

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.

$pdf->textstart()
Forces the start of text mode while in graphics.
$pdf->textfont($fontobj, $size)
Define the current font to be an (already defined) font object at the given size.
$txt->textlead($leading)
Set the baseline-to-baseline "leading" to be used for text lines.
$pdf->text($string)
Applies (writes out) the given text at the current text location, using the already-specified font.
$pdf->nl()
Write a newline (drop down to the next line).
$pdf->textend()
Force an end to text output and return to graphics.
$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.

Alfred Reibenschuh

2021-03-28 perl v5.32.1