1PDF::Builder::Lite(3) User Contributed Perl DocumentationPDF::Builder::Lite(3)
2
3
4
6 PDF::Builder::Lite - Lightweight PDF creation methods
7
9 $pdf = PDF::Builder::Lite->new();
10 $pdf->page(595,842);
11 $img = $pdf->image('some.jpg');
12 $font = $pdf->corefont('Times-Roman');
13 $font = $pdf->ttfont('TimesNewRoman.ttf');
14
16 This class is unmaintained (since 2007) and should not be used in new
17 code. It combines many of the methods from PDF::Builder and
18 PDF::Builder::Content into a single class but isn't really otherwise
19 any easier to use.
20
21 There have been many improvements and clarifications made to the rest
22 of the distribution that aren't reflected here, so the term "Lite" no
23 longer applies. It remains solely for compatibility with existing
24 legacy code.
25
27 $pdf = PDF::Builder::Lite->new(%opts)
28 $pdf = PDF::Builder::Lite->new()
29 $pdf->page()
30 $pdf->page($width,$height)
31 $pdf->page($llx,$lly, $urx,$ury)
32 Opens a new page.
33
34 $pdf->mediabox($w,$h)
35 $pdf->mediabox($llx,$lly, $urx,$ury)
36 Sets the global mediabox.
37
38 $pdf->saveas($file)
39 Saves the document (may not be modified later) and deallocates the
40 PDF structures.
41
42 If $file is just a hyphen '-', the stringified copy is returned,
43 otherwise the file is saved, and $self is returned (for chaining
44 calls).
45
46 $font = $pdf->corefont($fontname)
47 Returns a new or existing Adobe core font object.
48
49 Examples:
50
51 $font = $pdf->corefont('Times-Roman');
52 $font = $pdf->corefont('Times-Bold');
53 $font = $pdf->corefont('Helvetica');
54 $font = $pdf->corefont('ZapfDingbats');
55
56 $font = $pdf->ttfont($ttfile)
57 Returns a new or existing TrueType font object.
58
59 Examples:
60
61 $font = $pdf->ttfont('TimesNewRoman.ttf');
62 $font = $pdf->ttfont('/fonts/Univers-Bold.ttf');
63 $font = $pdf->ttfont('../Democratica-SmallCaps.ttf');
64
65 $font = $pdf->psfont($ps_file, %options)
66 $font = $pdf->psfont($ps_file)
67 Returns a new Type1 (PS) font object.
68
69 Examples:
70
71 $font = $pdf->psfont('TimesRoman.pfa', 'afmfile' => 'TimesRoman.afm', 'encode' => 'latin1');
72 $font = $pdf->psfont('/fonts/Univers.pfb', 'pfmfile' => '/fonts/Univers.pfm', 'encode' => 'latin2');
73
74 $egs = $pdf->create_egs()
75 Returns a new extended-graphics-state object.
76
77 Examples:
78
79 $egs = $pdf->create_egs();
80
81 $img = $pdf->image_jpeg($file)
82 Returns a new JPEG image object.
83
84 $img = $pdf->image_png($file)
85 Returns a new PNG image object.
86
87 $img = $pdf->image_tiff($file, %opts)
88 $img = $pdf->image_tiff($file)
89 Returns a new TIFF image object.
90
91 $img = $pdf->image_pnm($file)
92 Returns a new PNM image object.
93
94 $pdf->savestate()
95 Saves the state of the page.
96
97 $pdf->restorestate()
98 Restores the state of the page.
99
100 $pdf->egstate($egs)
101 Sets extended-graphics state.
102
103 $pdf->fillcolor($color)
104 Sets the fill color. See "strokecolor" for color names and
105 specifications.
106
107 $pdf->strokecolor($color)
108 Sets the stroke color.
109
110 Defined color-names are:
111
112 aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond,
113 blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue,
114 cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen, darkgrey,
115 darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon,
116 darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet,
117 deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen,
118 fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew,
119 hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon,
120 lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgreen, lightgrey,
121 lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey,
122 lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine,
123 mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen,
124 mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite,
125 navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen,
126 paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple,
127 red, rosybrown, royalblue, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna,
128 silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal,
129 thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen
130
131 or the rgb-hex-notation:
132
133 #rgb, #rrggbb, #rrrgggbbb and #rrrrggggbbbb
134
135 or the cmyk-hex-notation:
136
137 %cmyk, %ccmmyykk, %cccmmmyyykkk and %ccccmmmmyyyykkkk
138
139 or the hsl-hex-notation:
140
141 &hsl, &hhssll, &hhhssslll and &hhhhssssllll
142
143 or the hsv-hex-notation:
144
145 !hsv, !hhssvv, !hhhsssvvv and !hhhhssssvvvv
146
147 $pdf->linedash(@dash)
148 Sets the line dash pattern.
149
150 $pdf->linewidth($width)
151 Sets the line width.
152
153 $pdf->transform(%opts)
154 Sets transformations (i.e., translate, rotate, scale, skew) in PDF-
155 canonical order.
156
157 Example:
158
159 $pdf->transform(
160 'translate' => [$x,$y],
161 'rotate' => $rot,
162 'scale' => [$sx,$sy],
163 'skew' => [$sa,$sb],
164 )
165
166 $pdf->move($x,$y)
167 Move to a new drawing location at C[$x,$y].
168
169 $pdf->line($x,$y)
170 Draw a line to C[$x,$y].
171
172 $pdf->curve($x1,$y1, $x2,$y2, $x3,$y3)
173 Draw a Bezier curve with three control points.
174
175 $pdf->arc($xc,$yc, $rx,$ry, $alpha,$beta, $move, $dir)
176 $pdf->arc($xc,$yc, $rx,$ry, $alpha,$beta, $move)
177 Draw an arc centered at C[$xc,$yc], with x radius C[$rx] and y
178 radius C[$ry], from C[$alpha] degrees to C[$beta] degrees. If
179 C[$move] is true, do not draw a line to the start of the arc.
180 C[$dir] defaults to 0 for counter-clockwise sweep, and may be set
181 to 1 for a clockwise sweep.
182
183 $pdf->ellipse($xc,$yc, $rx,$ry)
184 Draw an ellipse centered at C[$xc,$yc], with x radius C[$rx] and y
185 radius C[$ry].
186
187 $pdf->circle($xc,$yc, $r)
188 Draw a circle centered at C[$xc,$yc], of radius C[$r].
189
190 $pdf->rect($x,$y, $w,$h)
191 Draw a rectangle with lower left corner at C[$x,$y], width (+x)
192 C[$w] and height (+y) C[$h].
193
194 $pdf->rectxy($x1,$y1, $x2,$y2)
195 Draw a rectangle with opposite corners C[$x1,$y1] and C[$x2,$y2].
196
197 $pdf->poly($x1,$y1, ..., $xn,$yn)
198 Draw a polyline (multiple line segments) starting at (move to)
199 C[$x1,$y1] and continuing on to C[$x2,$y2], ..., C[$xn,$yn].
200
201 $pdf->close()
202 Close a shape (draw a line back to the beginning).
203
204 $pdf->stroke()
205 Stroke (actually draw) a shape whose path has already been laid
206 out, using the requested "strokecolor".
207
208 $pdf->fill()
209 Fill in a closed geometry (path), using the requested "fillcolor".
210 The non-zero winding rule is used if the path crosses itself.
211
212 $pdf->fillstroke()
213 Fill (using "fillcolor") and stroke (using "strokecolor") a closed
214 path. The non-zero winding rule is used if the path crosses
215 itself.
216
217 $pdf->image($imgobj, $x,$y, $w,$h)
218 $pdf->image($imgobj, $x,$y, $scale)
219 $pdf->image($imgobj, $x,$y)
220 Please Note: The width/height or scale given is in user-space
221 coordinates, which are subject to transformations which may have
222 been specified beforehand.
223
224 Per default this has a 72dpi resolution, so if you want an image to
225 have a 150 or 300dpi resolution, you should specify a scale of
226 72/150 (or 72/300) or adjust width/height accordingly.
227
228 $pdf->textstart()
229 Forces the start of text mode while in graphics.
230
231 $pdf->textfont($fontobj, $size)
232 Define the current font to be an (already defined) font object at
233 the given size.
234
235 $txt->textleading($leading)
236 Set the baseline-to-baseline "leading" to be used for text lines.
237
238 $txt->textlead($leading)
239 Set the baseline-to-baseline "leading" to be used for text lines.
240
241 Deprecated, will be removed March 2023 or later. Use textleading().
242
243 $pdf->text($string)
244 Applies (writes out) the given text at the current text location,
245 using the already-specified font.
246
247 $pdf->nl()
248 Write a newline (drop down to the next line).
249
250 $pdf->textend()
251 Force an end to text output and return to graphics.
252
253 $pdf->print($font, $size, $x,$y, $rot, $just, $text)
254 Convenience wrapper for shortening the textstart..textend sequence.
255
256 Go into text mode, set the font to the object and size, go to the
257 location, set any rotation, set justification, and write the array
258 of text. Justification is 0 for left, 1 for center, and 2 for
259 right.
260
262 This module was originally written by Alfred Reibenschuh. It has had
263 some minor updates over time, but otherwise is mostly unchanged.
264
265
266
267perl v5.36.0 2023-01-23 PDF::Builder::Lite(3)