Does anybody have (or could write) a simple PDF::API2 main example that will traverse all the objects of an opened pdf file? I have spent some time now reading through the docs and googling for examples and I so far have either found no existing results (or have not discovered a proper google/PerlMonks search string).

More specifically, what I would like to do is open a pdf file and be able to traverse the (at least text) objects of the file and extract the info from each internal object (and now that I have identified these internal objects, be able to perhaps identify other meta information from the specific object). PDF::API2 appears to have this capability, but I have so far not been able to figure out how to do it.

I have already scoured Google and PerlMonks for information. I have found many really good threads discussing creating pdf documents. And even some threads that appear to answer my question, but all of the cited examples are no longer reachable.

I am still a bit hazy about how to even identify the display objects in the $pdf object. Ideally, I would like an example that opens a pdf with PDF::API2, shows how to identify/navigate through the object list/tree(?) and show how to extract text (and/or other information) from these internal objects.

Thanks in advance for any clues or help. :-D


In reply to PDF::API2 traversing object tree and parsing text by RandomMonkey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.