469,344 Members | 5,424 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,344 developers. It's quick & easy.

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

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
  2. #!/usr/local/bin/perl -w
  4. use CAM::PDF;
  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();
  12.     print "$pages\n";
  13. } else {
  14.     print qq{ERROR: Unreadable file '$ARGV[0]' or not a pdf\n};
  15. }

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
6 2703
971 Expert 512MB
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.

Mar 18 '08 #2
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
Ok i went to shell and tried running it and got this error:

Permission denied

Mar 18 '08 #4
changed permissions on the perl file and now get

ERROR: Cannot find the index in the PDF content

Mar 18 '08 #5
971 Expert 512MB
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?

Mar 18 '08 #6
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.

Similar topics

3 posts views Thread by lonelyplanet999 | last post: by
2 posts views Thread by Paul Porcelli | last post: by
reply views Thread by Kirt Loki Dankmyer | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.