1PDF::Create::Page(3)  User Contributed Perl Documentation PDF::Create::Page(3)
2
3
4

NAME

6       PDF::Create::Page - PDF pages tree for PDF::Create
7

VERSION

9       Version 1.46
10

DESCRIPTION

12       FOR INTERNAL USE ONLY
13

METHODS

15   add($id, $name)
16       Adds a page to the PDF document.
17
18   count()
19       Returns page count.
20
21   kids()
22       Returns ref to a list of page ids.
23
24   list()
25       Returns page list.
26
27   new_page()
28       Return new page.
29
30   moveto($x, $y)
31       Moves the current point to (x, y), omitting any connecting line
32       segment.
33
34   lineto($x, $y)
35       Appends a straight line segment from the current point to (x, y).
36
37   curveto($x1, $y1, $x2, $y2, $x3, $y3)
38       Appends a Bezier  curve  to the path. The curve extends from the
39       current point to (x3 ,y3) using (x1 ,y1) and (x2 ,y2) as the Bezier
40       control points.The new current point is (x3 ,y3).
41
42   rectangle($x, $y, $w, $h)
43       Adds a rectangle to the current path.
44
45   closepath()
46       Closes the current subpath by appending a straight line segment from
47       the current point to the starting point of the subpath.
48
49   newpath()
50       Ends the path without filling or stroking it.
51
52   stroke()
53       Strokes the path.
54
55   closestroke()
56       Closes and strokes the path.
57
58   fill()
59       Fills the path using the non-zero winding number rule.
60
61   fill2()
62       Fills the path using the even-odd rule.
63
64   line($x1, $y1, $x2, $y2)
65       Draw a  line between ($x1, $y1) and ($x2, $y2). Combined moveto /
66       lineto / stroke command.
67
68   set_width($w)
69       Set the width of subsequent lines to "w" points.
70
71   setgray($value)
72       Sets the color space to DeviceGray and sets the gray tint to use for
73       filling paths.
74
75   setgraystroke($value)
76       Sets the color space to DeviceGray and sets the gray tint to use for
77       stroking paths.
78
79   setrgbcolor($r, $g, $b)
80       Sets the fill colors used for normal text or filled objects.
81
82   setrgbcolorstroke($r, $g, $b)
83       Set the color  of the subsequent drawing operations. Valid r, g, and b
84       values are each between 0.0 and 1.0, inclusive.
85
86       Each color ranges from 0.0 to 1.0, i.e., darkest red (0.0) to brightest
87       red(1.0).  The same holds for green and blue.  These three colors mix
88       additively to produce the colors between black (0.0, 0.0, 0.0) and
89       white (1.0, 1.0, 1.0).
90
91       PDF distinguishes between  the stroke  and  fill operations and
92       provides separate color settings for each.
93
94   text(%params)
95       Renders the text. Parameters are explained as below:
96
97           +--------+------------------------------------------------------------------+
98           | Key    | Description                                                      |
99           +--------+------------------------------------------------------------------+
100           | start  | The start marker, add directive BT                               |
101           | end    | The end marker, add directive ET                                 |
102           | text   | Text to add to the pdf                                           |
103           | F      | Font index to be used, add directive /F<font_index>              |
104           | Tf     | Font size for the text, add directive <font_size> Tf             |
105           | Ts     | Text rise (super/subscript), add directive <mode> Ts             |
106           | Tr     | Text rendering mode, add directive <mode> Tr                     |
107           | TL     | Text leading, add directive <number> TL                          |
108           | Tc     | Character spacing, add directive <number> Tc                     |
109           | Tw     | Word spacing, add directive <number> Tw                          |
110           | Tz     | Horizontal scaling, add directive <number> Tz                    |
111           | Td     | Move to, add directive <x> <y> Td                                |
112           | TD     | Move to and set TL, add directive <x> <y> TD                     |
113           | rot    | Move to and rotate (<r> <x> <y>), add directive                  |
114           |        | <cos(r)>, <sin(r)>, <sin(r)>, <cos(r)>, <x>, <y> Tm              |
115           | T*     | Add new line.                                                    |
116           +--------+------------------------------------------------------------------+
117
118   string($font, $size, $x, $y, $text $alignment)
119       Add text to the current page using the font object at the given size
120       and position.  The point (x, y) is the bottom left corner of the
121       rectangle containing the text.
122
123       The optional alignment can be 'r' for right-alignment and 'c' for
124       centered.
125
126       Example :
127
128           my $f1 = $pdf->font(
129              'Subtype'  => 'Type1',
130              'Encoding' => 'WinAnsiEncoding',
131              'BaseFont' => 'Helvetica'
132           );
133
134           $page->string($f1, 20, 306, 396, "some text");
135
136   string_underline($font, $size, $x, $y, $text, $alignment)
137       Draw a line for underlining.The parameters are the same as for the
138       string function but only the line is drawn. To draw an underlined
139       string you must call both,string and string_underline. To change the
140       color of  your text  use the "setrgbcolor()".  It  returns the length
141       of the string. So its return value can be used directly for the
142       bounding box of an annotation.
143
144       Example :
145
146           $page->string($f1, 20, 306, 396, "some underlined text");
147
148           $page->string_underline($f1, 20, 306, 396, "some underlined text");
149
150   stringl($font, $size, $x, $y $text)
151       Same as "string()".
152
153   stringr($font, $size, $x, $y, $text)
154       Same as "string()" but right aligned (alignment 'r').
155
156   stringc($font, $size, $x, $y, $text)
157       Same as "string()" but centered (alignment 'c').
158
159   string_width($font, $text)
160       Return the size of the text using the given font in default user space
161       units.This does not contain the size of the font yet, to get the length
162       you must multiply by the font size.
163
164   printnl($text, $font, $size, $x, $y)
165       Similar to  "string()" but parses the string for newline and prints
166       each part on a separate line. Lines spacing is the same as the
167       font-size.Returns the number of lines.
168
169       Note the different parameter sequence.The first call should specify all
170       parameters, font is  the absolute minimum, a warning will be given for
171       the missing y position and 800  will  be assumed. All subsequent
172       invocations can omit all but the string parameters.
173
174       ATTENTION:There is no provision for changing pages.If you run out of
175       space on the current page this will draw the string(s) outside the page
176       and it will be invisible.
177
178   block_text(\%params)
179       Add block of text to the page. Parameters are explained as below:
180
181           +------------+--------------------------------------------------------------+
182           | Key        | Description                                                  |
183           +------------+--------------------------------------------------------------+
184           | page       | Object of type PDF::Create::Page                             |
185           | font       | Font index to be used.                                       |
186           | text       | Text block to be used.                                       |
187           | font_size  | Font size for the text.                                      |
188           | text_color | Text color as arrayref i.e. [r, g, b]                        |
189           | line_width | Line width (in points)                                       |
190           | start_y    | First row number (in points) when adding new page.           |
191           | end_y      | Last row number (in points) when to add new page.            |
192           | x          | x co-ordinate to start the text.                             |
193           | y          | y co-ordinate to start the text.                             |
194           +------------+--------------------------------------------------------------+
195
196           use strict; use warnings;
197           use PDF::Create;
198
199           my $pdf  = PDF::Create->new('filename'=>"$0.pdf", 'Author'=>'MANWAR', 'Title'=>'Create::PDF');
200           my $root = $pdf->new_page('MediaBox' => $pdf->get_page_size('A4'));
201           my $page = $root->new_page;
202           my $font = $pdf->font('BaseFont' => 'Helvetica');
203
204           $page->rectangle(30, 780, 535, 40);
205           $page->setrgbcolor(0,1,0);
206           $page->fill;
207
208           $page->setrgbcolorstroke(1,0,0);
209           $page->line(30, 778, 565, 778);
210
211           $page->setrgbcolor(0,0,1);
212           $page->string($font, 15, 102, 792, 'MANWAR - PDF::Create');
213
214           my $text = qq{
215       Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into ele-It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions
216           };
217
218           $page->block_text({
219               page       => $page,
220               font       => $font,
221               text       => $text,
222               font_size  => 6,
223               text_color => [0,0,1],
224               line_width => 535,
225               start_y    => 780,
226               end_y      => 60,
227               'x'        => 30,
228               'y'        => 770,
229           });
230
231           $pdf->close;
232
233   image(%params)
234       Inserts an image. Parameters can be:
235
236           +----------------+----------------------------------------------------------+
237           | Key            | Description                                              |
238           +----------------+----------------------------------------------------------+
239           |                |                                                          |
240           | image          | Image id returned by PDF::image (required).              |
241           |                |                                                          |
242           | xpos, ypos     | Position of image (required).                            |
243           |                |                                                          |
244           | xalign, yalign | Alignment of image.0 is left/bottom, 1 is centered and 2 |
245           |                | is right, top.                                           |
246           |                |                                                          |
247           | xscale, yscale | Scaling of image. 1.0 is original size.                  |
248           |                |                                                          |
249           | rotate         | Rotation of image.0 is no rotation,2*pi is 360° rotation.|
250           |                |                                                          |
251           | xskew, yskew   | Skew of image.                                           |
252           |                |                                                          |
253           +----------------+----------------------------------------------------------+
254
255       Example jpeg image:
256
257           # include a jpeg image with scaling to 20% size
258           my $jpg = $pdf->image("image.jpg");
259
260           $page->image(
261               'image'  => $jpg,
262               'xscale' => 0.2,
263               'yscale' => 0.2,
264               'xpos'   => 350,
265               'ypos'   => 400
266           );
267

AUTHORS

269       Fabien Tassin
270
271       GIF and JPEG-support: Michael Gross (info@mdgrosse.net)
272
273       Maintenance since 2007: Markus Baertschi (markus@markus.org)
274
275       Currently maintained by Mohammad S Anwar (MANWAR) "<mohammad.anwar at
276       yahoo.com>"
277

REPOSITORY

279       <https://github.com/manwar/pdf-create>
280
282       Copyright 1999-2001,Fabien Tassin.All rights reserved.It may be used
283       and modified freely, but I do  request that this copyright notice
284       remain attached to the file.  You may modify this module as you
285       wish,but if you redistribute a modified version, please attach a note
286       listing the modifications you have made.
287
288       Copyright 2007 Markus Baertschi
289
290       Copyright 2010 Gary Lieberman
291

LICENSE

293       This is free software; you can redistribute it and / or modify it under
294       the same terms as Perl 5.6.0.
295
296
297
298perl v5.34.0                      2022-01-21              PDF::Create::Page(3)
Impressum