Text::PDF::Page(3pm)

πŸ“¦
version 0.31 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

✨ Text::PDF::Page ✨

okay bestie, welcome to Text::PDF::Page πŸ’– (that's the Text::PDF::Page(3pm) page from the User Contributed Perl Documentation, if you're keeping receipts). It's the module that represents a <rainbow>PDF page</rainbow>, and plot twist: it inherits from Text::PDF::Pages. Yes, the name is so close to its parent, no cap. It's giving "family business" πŸ’…


πŸ¦‹ NAME πŸ¦‹

Text::PDF::Page β€” the whole entire vibe is: it Represents a PDF page, and it inherits from Text::PDF::Pages. That's the tea. πŸ«–


🌸 DESCRIPTION 🌸

So like. This class represents a page of output in PDF. That's the main character job. πŸŽ€

But it's not just sitting there looking pretty β€” it also keeps track of the content stream, plus any resources (such as fonts) that are being switched, etc. Little bookkeeper energy. ✨

Now, about that inheritance situation: Page inherits from Pages because of a number of shared methods. That's the only reason, bestie, I promise. Because structurally? They are really quite different. Like, same surname, completely different personality. πŸ’€


πŸ’œ INSTANCE VARIABLES πŸ’œ

A page has various working variables, and here's the one that matters:

  • curstrm β€” the currently open stream. That's it, that's the variable. πŸ“

⭐ METHODS ⭐

🌈 Text::PDF::Page->new($pdf, $parent, $index)

Creates a new page based on a pages object (perhaps the root object). Slay, new page just dropped. πŸ‘‘

Important detail, don't skip this part: the page is also added to the parent at this point. Which means pages get ordered in a PDF document in the order in which they are created, rather than in the order they are closed. Big difference, keep that in mind. 🧚

Only the essential elements in the page dictionary are created here β€” everything else is either optional or can be inherited. Minimal effort, maximal inheritance. Periodt. πŸ’…

The optional index value indicates the index in the parent list that this page should be inserted, so that new pages need not be appended. Fancy positioning, we love to see it. ✨

🌸 $p->add($str)

Adds the string to the currently active stream for this page. And if no stream exists yet? No worries β€” one gets created and added to the list of streams for this page. 🫢

Also, about the name: the slightly cryptic add is a deliberate aim to keep it short, given the number of times people are likely to have to type it. It's a convenience name and honestly? Respect. 😌

πŸ¦‹ $p->ship_out($pdf)

Ships the page out to the given output file context. Bye bestie, go be a real PDF now. πŸ‘‹πŸ’–


lowkey a whole little module. it inherits, it tracks streams, it ships out. iconic behaviour only. πŸŽ€

and that's the page!! 🌈 brought to you by perl v5.36.0, dated 2022-10-22, straight outta the User Contributed Perl Documentation. mwah, go make some PDF pages bestie πŸ’…βœ¨

πŸ“¦ where this page comes from