PDF::AP...DF::Dict(3)

πŸ’– NAME πŸ’–

PDF::API2::Basic::PDF::Dict β€” okay bestie, this is the low-level dictionary and stream object situation. It's a Perl man page from section 3 (User Contributed Perl Documentation), and it's giving "I'm the plumbing behind your PDFs" energy. No cap. 🫢


✨ INSTANCE VARIABLES ✨

So there are these special instance variables that exist mostly to babysit streams, and here's the iconic detail: every single one of them starts with a space. Yes, a literal space. That's not a typo, that's the whole vibe. πŸŽ€

  • stream β€” holds the stream contents for output. Simple. Elegant. Main character.
  • streamfile β€” holds the stream contents in an external file instead of in memory. And ngl, important note: this is not the same as a PDF file stream. The data is stored in its unfiltered form. πŸ’…
  • streamloc β€” if both stream and streamfile are empty, this tells you where in the source PDF the stream starts. It's the little map pin. πŸ“

🌈 METHODS 🌈

πŸ¦‹ $type = $d->type($type)

Get/Set the standard Type key. You can pass it a text value and it'll hand you back a text value too β€” not a Name object. It's giving convenient. ✨

πŸ¦‹ @filters = $d->filter(@filters)

Get/Set one or more filters that the optional stream attached to the dictionary is using. Plural filters, plural business. πŸ’œ

πŸ¦‹ $d->outobjdeep($fh)

Outputs the contents of the dictionary to a PDF file. Heads up: this is a recursive call, so it goes deep-deep, iykyk. πŸ”₯

It also outputs a stream if the dictionary has a stream element. And when that happens? This method calculates the length of the stream and inserts it into the stream's dictionary. It's doing the math for you, bestie, you're welcome. 😌

πŸ¦‹ $d->read_stream($force_memory)

Reads in a stream from a PDF file. Here's where it gets interesting: if the stream is greater than PDF::Dict::mincache bytes to be stored, the default action is to create a file for it somewhere and use that file as a data cache. And what's the default value of PDF::Dict::mincache? It's 32768. Remember that number, it might come up. πŸ“

But if $force_memory is set, that caching will not happen β€” the data all gets stored in the $self->{' stream'} variable instead. Straight into memory, no detours. πŸ’€

πŸ¦‹ $d->val

Returns the dictionary. Which is itself. It's the dictionary returning itself, which is honestly the most self-assured thing I've ever seen. πŸ‘‘ It's giving main character energy fr fr.


Okay but for real: those variable names all start with a space. stream, streamfile, streamloc. Miss that space and you're gonna have a bad time. πŸ™ˆ

And that's the whole page, bestie! πŸŽ€ Sending you off with the deets from the footer: this was perl v5.42.0, dated 2025-09-01, and it lives under PDF::AP...DF::Dict(3) β€” slay, go forth and dictionary responsibly. πŸ’–βœ¨πŸ¦‹

πŸ“¦ 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