By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,282 Members | 1,617 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,282 IT Pros & Developers. It's quick & easy.

Perl Script that returns the number of pages in a PDF (used to work)

P: 8
I had this script that used to work in order to return the number of pages but it does not seem to work anymore.
Expand|Select|Wrap|Line Numbers
  1.  
  2. #!/usr/local/bin/perl -w
  3.  
  4. use CAM::PDF;
  5.  
  6. if (defined($ARGV[0]) && -r $ARGV[0] && $ARGV[0] =~ /\.pdf/i) {
  7.     my $pdf_file = $ARGV[0];
  8.     my $doc = CAM::PDF->new($pdf_file, q{}, q{}, 1) || die "ERROR: $CAM::PDF::errstr\n";
  9.     my $size = length $doc->{content};
  10.     my $pages = $doc->numPages();
  11.  
  12.     print "$pages\n";
  13. } else {
  14.     print qq{ERROR: Unreadable file '$ARGV[0]' or not a pdf\n};
  15. }
  16.  
  17.  
  18.  


Now when I try running it, All I get is the error

please let me know if you see anything wrong
Mar 18 '08 #1
Share this Question
Share on Google+
6 Replies


eWish
Expert 100+
P: 971
The code will not just stop working something was changed. It is a matter of figuring out changed. Has the module that you are using been updated? Have there been any changes to the server? What errors are you getting, please post the errors.

--Kevin
Mar 18 '08 #2

P: 8
Honestly I am just a new programmer on staff. Best of my knowledge nothing was.
And I am not too good at Perl. I call this module via PHP. Just wanted to see if everything looked OK here.


We have had some server inconsistencies. I am just trying to go through a process of elimination.

Oh and thanks for the quick reply
Mar 18 '08 #3

P: 8
Ok i went to shell and tried running it and got this error:

//////////////////
Permission denied

/////////////
Mar 18 '08 #4

P: 8
changed permissions on the perl file and now get


ERROR: Cannot find the index in the PDF content


Sigh!!!
Mar 18 '08 #5

eWish
Expert 100+
P: 971
I don't see anything in the code that you posted that requires any authentication. So, it does not appear to be an issue with the code posted. Are the PDF files password protected? Are you requiring authentication to the directory where the files are located?

--Kevin
Mar 18 '08 #6

P: 8
Ok so this is what i found out. I can run the scripts in shell. But not when it comes to me running it from PHP

any insights ?
Mar 18 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.