sub pdf_pagecount {
scalar @_ or confess('missing arg');
my $count=0;
require PDF::API2;
require Carp;
PDFILE : while( my $abs = shift @_){
-f $abs or Carp::cluck("!-f $abs") and return 0;
my $p = PDF::API2->open($abs) or die;
my $_count;
unless( $_count = $p->pages ){
Carp::cluck("doc $abs had no pagecount?");
next PDFILE;
}
$count= ($count + $_count);
}
return $count;
}
Arg is abs path to pdf tests for existance returns count of pages. Arg can be list, checks each and warns and returns false on errors.
my $pagecount= pdf_pagecount(’/my/abs/file.pdf’);
my $total_pagecount= pdf_pagecount( '/my/abs/file.pdf’, ’/my/abs/file
+2.pdf’,);
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|