Hi All, looking for a way of reading the Page Label from a PDF in Perl; and if that's not possible then a way of adding / reading metadata.

Problem I'm working to solve is that I'm using a PDF file as a 'template', and then reading in another file of 'data', and then based on the dynamic data, the script is keyed to extract a page from the template and insert into a new pdf (each template page being potentially recycled n times for each completed output pdf).

This is working, and for proof of concept I keyed the script to use page_numbers (page 1 is a basic contents page template, page 2 is a legaleaze disclaimer page that is added at the end of a set of pages for each member for example) in the template pdf, however I need a way of expressing to the script which pages are which for the eventual production environment; they won't always be arbitrary page 1 = this, page 2 = this; sometimes the template may have up to six different pages, each with a different purpose.

Was thinking an easy way of addressing this was to give each page a label and then keying the script off of the label names, however I can't figure out how to extract the page label from the input pdf template; only how to set a label.

Currently using the PDF::API2 library, however am open to using any library in order to read and extra the page_label=page_number information (that'll be stored in an eventual hash / associative array).

Appreciate any and all assistance, and I apologize for rudimentary post, it's my first attempt reaching out.

Thank you!


In reply to Reading page label (name) from PDF file... by squirly

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.