PDF::C...e::Page(3pm)

πŸ“¦
version 1.46 Β· 3 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

✨ 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 directive BT
  • end β€” The end marker, add directive ET
  • text β€” Text to add to the pdf
  • F β€” Font index to be used, add directive /F<font_index>
  • Tf β€” Font size for the text, add directive <font_size> Tf
  • Ts β€” Text rise (super/subscript), add directive <mode> Ts
  • Tr β€” Text rendering mode, add directive <mode> Tr
  • TL β€” Text leading, add directive <number> TL
  • Tc β€” Character spacing, add directive <number> Tc
  • Tw β€” Word spacing, add directive <number> Tw
  • Tz β€” Horizontal scaling, add directive <number> Tz
  • Td β€” Move to, add directive <x> <y> Td
  • TD β€” Move to and set TL, add directive <x> <y> TD
  • rot β€” Move to and rotate (<r> <x> <y>), add directive <cos(r)>, <sin(r)>, <sin(r)>, <cos(r)>, <x>, <y> Tm
  • T* β€” 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 type PDF::Create::Page
  • font β€” 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 by PDF::image (required).
  • xpos, ypos β€” Position of image (required).
  • xalign, yalign β€” Alignment of image. 0 is left/bottom, 1 is centered and 2 is right, top.
  • xscale, yscale β€” Scaling of image. 1.0 is original size.
  • rotate β€” Rotation of image. 0 is no rotation, 2*pi is 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. πŸ¦‹


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