PDF::C...e::Page(3pm)
β¨ NAME β¨
PDF::Create::Page β PDF pages tree for PDF::Create π
okay so first thing, bestie: the header line up top is PDF::C...e::Page(3pm) from the User Contributed Perl Documentation, and yeah it's literally truncated like that, iykyk π. The actual name is PDF::Create::Page, and it's the pages-tree situation for PDF::Create. that's the vibe. periodt.
π VERSION π
Version 1.46 β¨
π¨ DESCRIPTION π¨
FOR INTERNAL USE ONLY
ngl this is the entire description and it's giving "you were NOT supposed to find this file" π but here we are, and honestly? iconic behavior. it's internal only, so treat it like the group chat screenshot β read it, don't touch it π
π οΈ METHODS π οΈ
okay this is the good part, buckle up πΈ
add($id, $name)
Adds a page to the PDF document. that's it, that's the whole job π
count()
Returns page count. slay, a counter. β¨
kids()
Returns ref to a list of page ids. π
list()
Returns page list. π¦
new_page()
Return new page. πΈ
moveto($x, $y)
Moves the current point to (x, y), and it omits any connecting line segment β so like, no little line gets drawn to get you there, you just appear. main character teleport energy fr π
lineto($x, $y)
Appends a straight line segment from the current point to (x, y). ποΈ
curveto($x1, $y1, $x2, $y2, $x3, $y3)
Appends a Bezier curve to the path. The curve extends from the current point to (x3 ,y3) using (x1 ,y1) and (x2 ,y2) as the Bezier control points. The new current point is (x3 ,y3). β¨ curves, we love a little bend π
rectangle($x, $y, $w, $h)
Adds a rectangle to the current path. simple. gorgeous. four sides. π
closepath()
Closes the current subpath by appending a straight line segment from the current point to the starting point of the subpath. π«Ά
newpath()
Ends the path without filling or stroking it. so it justβ¦ ends. no drama, no paint. π
stroke()
Strokes the path. π
closestroke()
Closes and strokes the path. both things. at once. multifunctional queen π
fill()
Fills the path using the non-zero winding number rule. π
fill2()
Fills the path using the even-odd rule. π§
line($x1, $y1, $x2, $y2)
Draw a line between ($x1, $y1) and ($x2, $y2). It's a combined moveto / lineto / stroke command, so it's the whole glow-up in one call π₯
set_width($w)
Set the width of subsequent lines to w points. π
setgray($value)
Sets the color space to DeviceGray and sets the gray tint to use for filling paths. π©Ά
setgraystroke($value)
Sets the color space to DeviceGray and sets the gray tint to use for stroking paths. π©Ά
setrgbcolor($r, $g, $b)
Sets the fill colors used for normal text or filled objects. π
setrgbcolorstroke($r, $g, $b)
Set the color of the subsequent drawing operations. Valid r, g, and b values are each between 0.0 and 1.0, inclusive. π¨
Each color ranges from 0.0 to 1.0, i.e., darkest red (0.0) to brightest red (1.0). The same holds for green and blue. These three colors mix additively to produce the colors between black (0.0, 0.0, 0.0) and white (1.0, 1.0, 1.0). no cap, that's just how additive mixing works β¨
PDF distinguishes between the stroke and fill operations and provides separate color settings for each. so yeah, two different color settings, don't mix them up bestie π
text(%params)
Renders the text. Parameters are explained as below: π
startβ The start marker, add directiveBTendβ The end marker, add directiveETtextβ Text to add to the pdfFβ Font index to be used, add directive/F<font_index>Tfβ Font size for the text, add directive<font_size> TfTsβ Text rise (super/subscript), add directive<mode> TsTrβ Text rendering mode, add directive<mode> TrTLβ Text leading, add directive<number> TLTcβ Character spacing, add directive<number> TcTwβ Word spacing, add directive<number> TwTzβ Horizontal scaling, add directive<number> TzTdβ Move to, add directive<x> <y> TdTDβ Move to and set TL, add directive<x> <y> TDrotβ Move to and rotate (<r> <x> <y>), add directive<cos(r)>, <sin(r)>, <sin(r)>, <cos(r)>, <x>, <y> TmT*β Add new line.
string($font, $size, $x, $y, $text $alignment)
Add text to the current page using the font object at the given size and position. The point (x, y) is the bottom left corner of the rectangle containing the text. π
The optional alignment can be 'r' for right-alignment and 'c' for centered.
Example :
my $f1 = $pdf->font(
'Subtype' => 'Type1',
'Encoding' => 'WinAnsiEncoding',
'BaseFont' => 'Helvetica'
);
$page->string($f1, 20, 306, 396, "some text");
string_underline($font, $size, $x, $y, $text, $alignment)
Draw a line for underlining. The parameters are the same as for the string function but only the line is drawn. To draw an underlined string you must call both, string and string_underline. To change the color of your text use the setrgbcolor(). It returns the length of the string. So its return value can be used directly for the bounding box of an annotation. ποΈ
Example :
$page->string($f1, 20, 306, 396, "some underlined text");
$page->string_underline($f1, 20, 306, 396, "some underlined text");
stringl($font, $size, $x, $y $text)
Same as string(). π
stringr($font, $size, $x, $y, $text)
Same as string() but right aligned (alignment 'r'). β‘οΈ
stringc($font, $size, $x, $y, $text)
Same as string() but centered (alignment 'c'). π―
string_width($font, $text)
Return the size of the text using the given font in default user space units. This does not contain the size of the font yet, to get the length you must multiply by the font size. bestie, do NOT forget the multiplication, it's literally the whole point π
printnl($text, $font, $size, $x, $y)
Similar to string() but parses the string for newline and prints each part on a separate line. Lines spacing is the same as the font-size. Returns the number of lines. β¨
Note the different parameter sequence. The first call should specify all parameters, font is the absolute minimum, a warning will be given for the missing y position and 800 will be assumed. All subsequent invocations can omit all but the string parameters. π
ATTENTION: There is no provision for changing pages. If you run out of space on the current page this will draw the string(s) outside the page and it will be invisible. π fr fr, it just vanishes off the edge and you get nothing. plan your page space, girlie π«Ά
block_text(\%params)
Add block of text to the page. Parameters are explained as below: π
pageβ Object of typePDF::Create::Pagefontβ Font index to be used.textβ Text block to be used.font_sizeβ Font size for the text.text_colorβ Text color as arrayref i.e.[r, g, b]line_widthβ Line width (in points)start_yβ First row number (in points) when adding new page.end_yβ Last row number (in points) when to add new page.xβ x co-ordinate to start the text.yβ y co-ordinate to start the text.
use strict; use warnings;
use PDF::Create;
my $pdf = PDF::Create->new('filename'=>"$0.pdf", 'Author'=>'MANWAR', 'Title'=>'Create::PDF');
my $root = $pdf->new_page('MediaBox' => $pdf->get_page_size('A4'));
my $page = $root->new_page;
my $font = $pdf->font('BaseFont' => 'Helvetica');
$page->rectangle(30, 780, 535, 40);
$page->setrgbcolor(0,1,0);
$page->fill;
$page->setrgbcolorstroke(1,0,0);
$page->line(30, 778, 565, 778);
$page->setrgbcolor(0,0,1);
$page->string($font, 15, 102, 792, 'MANWAR - PDF::Create');
my $text = qq{
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
};
$page->block_text({
page => $page,
font => $font,
text => $text,
font_size => 6,
text_color => [0,0,1],
line_width => 535,
start_y => 780,
end_y => 60,
'x' => 30,
'y' => 770,
});
$pdf->close;
image(%params)
Inserts an image. Parameters can be: πΌοΈ
imageβ Image id returned byPDF::image(required).xpos,yposβ Position of image (required).xalign,yalignβ Alignment of image.0is left/bottom,1is centered and2is right, top.xscale,yscaleβ Scaling of image.1.0is original size.rotateβ Rotation of image.0is no rotation,2*piis 360Β° rotation.xskew,yskewβ Skew of image.
Example jpeg image: πΈ
# include a jpeg image with scaling to 20% size
my $jpg = $pdf->image("image.jpg");
$page->image(
'image' => $jpg,
'xscale' => 0.2,
'yscale' => 0.2,
'xpos' => 350,
'ypos' => 400
);
okay bestie that's only part 1, and there is SO much more coming, so don't go anywhere π
π AUTHORS π
okay so this module has been through a whole glow-up journey and honestly every single person on this list ate:
- Fabien Tassin β the original icon, the blueprint, the moment π
- GIF and JPEG-support: Michael Gross (
info@mdgrosse.net) β bestie really said "let there be pictures" πΌοΈβ¨ - Maintenance since 2007: Markus Baertschi (
markus@markus.org) β carrying the torch, no cap π«Ά - Currently maintained by Mohammad S Anwar (MANWAR)
"<mohammad.anwar at yahoo.com>"β the current main character holding it down π
like. a whole relay race of legends. we love to see it. π
π REPOSITORY π
the holy land, the source of truth, the place where the code lives and breathes:
<https://github.com/manwar/pdf-create>
go there. star it. read the commits. it's giving community. π¦
Β©οΈ COPYRIGHT Β©οΈ
okay so legal stuff but make it β¨aestheticβ¨ β read carefully bestie, this is real:
Copyright 1999-2001,Fabien Tassin.All rights reserved.It may be used and modified freely, but I do request that this copyright notice remain attached to the file. You may modify this module as you wish,but if you redistribute a modified version, please attach a note listing the modifications you have made.
Copyright 2007 Markus Baertschi
Copyright 2010 Gary Lieberman
tl;dr: use it, change it, ship it β just leave the copyright notice attached and if you fork it up and share the modified version, drop a lil note about what you changed. that's it. that's the ask. π€
π LICENSE π
this is free software; you can redistribute it and / or modify it under the same terms as Perl 5.6.0. πͺπ
like, genuinely free. as in freedom. as in go wild. periodt. π
okay and that's the whole page bestie!! we made it to the end and i'm lowkey emotional about it ππ
this was PDF::C...e::Page(3pm) from perl v5.38.2, dated 2024-03-07, brought to you by the Perl user-contributed docs squad π«Ά
now go make some PDFs, you gorgeous genius. slay. β¨ππ
π¦ where this page comes from
- debian trixie: libpdf-create-perl 1.46-3 Β· PDF-Create
- ubuntu resolute: libpdf-create-perl 1.46-3 Β· PDF-Create
- ubuntu stonking: libpdf-create-perl 1.46-3 Β· PDF-Create
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms