PDF::AP...::Pages(3)
π PDF::API2::Basic::PDF::Pages π
okay bestie, so this is PDF::API2::Basic::PDF::Pages from the User Contributed Perl Documentation β yes, the real one, the 3 section, we're doing the deep lore today β¨
πΈ NAME πΈ
PDF::API2::Basic::PDF::Pages β the low-level page tree object. Like, the actual scaffolding of your PDF. Not the glow-up, the bones. π¦
π DESCRIPTION π
So a Pages object is a parent. That's its whole thing. It's the mom of other pages objects, or of page objects themselves. It's giving family tree but make it PDF. π
β¨ METHODS β¨
π«Ά PDF::API2::Basic::PDF::Pages->new($pdf, $parent)
Okay so this one creates a brand-new Pages object inside a PDF. But heads up, bestie β the plot twist: $parent here is not the file context for the object. Nope. It's the parent pages object for this pages. Different thing. Stay with me. π
BUT β if you're using this class to create a root node, then $parent should point to the file context. And how do you clock the file context? It's the one that doesn't have a Type of Pages. iykyk π
And $pdf? That's the file object β or, plot twist number two, a reference to an array of file objects β in which you're creating the new Pages object. π
π
$p->find_page($page_number)
Hands you back the page you asked for, using the page count values in the pages tree. And here's the thing that trips everyone up: pages start at 0. Zero-indexed, no cap. Page one is page zero. Periodt. π
π $p->add_page($page, $page_number)
Slides your page in before the given $page_number. Cute.
Now the fun part β $page_number can be negative to count from the END of the document. So -1 is after the last page. Wild, I know, but that's literally what it says.
Likewise, $page_number can be greater than the number of pages currently in the document, which is how you append. Go off, append. π¦
π @objects = $p->get_pages()
Returns a list of page objects in the document, in page order. All of them. In order. Beautiful. No notes. β
π§ $p->find_prop($key)
Searches up through the inheritance tree to find a property. Climbing the family tree looking for your roots, basically. πΈ
π $p->add_font($pdf, $font)
Creates β or edits β the resource dictionary at this level in the hierarchy.
Important caveat though: if the font is already supported even through the hierarchy, then it is not added. It's already there, bestie, we're not duplicating. π«Ά
π $p->bbox($xmin, $ymin, $xmax, $ymax, [$param])
Specifies the bounding box for this and all child pages. Everyone inherits. Generational bounding box. π
Sneaky detail: if the values are identical to those inherited, then no change is made. Nothing to see here, move along. β¨
And $param? It specifies the attribute name β so that other 'bounding box'es can be set with this method. Yeah, other bounding boxes. Plural. Versatile king. π
π $p->proc_set(@entries)
Makes sure the current resource contains all the entries in the proc_sets you listed.
And if it doesn't? If necessary, it creates a local resource dictionary to make that happen. Doing it itself because nobody else will. main character energy fr fr. π₯
β $p->get_top
Returns the top of the pages tree. The tippy top. The crown. The root of it all. πΈ
Reminder bestie: pages start at 0,$parentis not the file context (unless you're making a root node, in which case it is, because it's the one without aTypeofPages), and-1inadd_pagemeans after the last page. These are the details that eat people alive. π
aaaand that's the whole page, bestie. This lil doc shipped in perl v5.42.0 and got dated 2025-09-01 β so go forth and build your page tree, you absolute icon. obsessed with you. bye! πβ¨ππ¦πΈπ
π¦ where this page comes from
- fedora 43: perl-PDF-API2 2.048-1.fc43 Β· LGPL-2.1-or-later AND (GPL-1.0-or-later OR Artistic-1.0-Perl) AND (MIT OR Artistic-1.0-Perl)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms