in reply to Reading page label (name) from PDF file...

Could you use a Document Property e.g. Keywords ?

#!/usr/bin/perl use strict; use PDF::API2; # A4 my $pdf = PDF::API2->new( width => 595, height => 842, ); my $page = $pdf->page; my $txt = $page->text; my $font = $pdf->corefont('Times-Roman'); $txt->font( $font, 32 ); $txt->translate( 100, 500 ); $txt->text( 'Test PDF with Keywords' ); my @pages = qw( PageName1 PageName2 PageName3 PageName4 PageName5 PageName6 PageName7 PageName8 PageName9 ); $pdf->info( 'Keywords' => join ';',@pages ); $pdf->saveas('template.pdf'); my $pdf1 = PDF::API2->open('template.pdf'); my %info = $pdf1->info(); my @pages = split ';',$info{'Keywords'}; print join "\n",@pages;
poj

Replies are listed 'Best First'.
Re^2: Reading page label (name) from PDF file...
by Anonymous Monk on May 25, 2016 at 18:14 UTC

    Thank you! That works!

    My original direction was to attempt to label the pages in order to get a handle on them; adding keyword meta data to describe the pages works equally well.

    I really appreciate your help.

    I used your code snippet and adapted to to read some custom tags in form of "stmnt1=1;disclaimer=2;etc" and it works!

    # retrieve page labels from pdf (specified in pdf keywords section as +pagelabel=#;pagelabel=#;pagelabel=#;etc...) my %info = $pdf_template->info(); my %page_labels = (); my @attributes; if (defined $info{'Keywords'}) { my @pages = split ';',$info{'Keywords'}; foreach (@pages) { @attributes = split "=",$_; $page_labels{$attributes[0]} = $attributes[1]; if (($debugging != 0 ) || ($verbose !=0 )) { print "$attributes[0]: $attributes[1]\n"; } } undef @pages; } undef %info; undef @attributes;