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