473,473 Members | 4,257 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

8 New Member
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
6 2891
eWish
971 Recognized Expert Contributor
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
2levelsabove
8 New Member
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
2levelsabove
8 New Member
Ok i went to shell and tried running it and got this error:

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

/////////////
Mar 18 '08 #4
2levelsabove
8 New Member
changed permissions on the perl file and now get


ERROR: Cannot find the index in the PDF content


Sigh!!!
Mar 18 '08 #5
eWish
971 Recognized Expert Contributor
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
2levelsabove
8 New Member
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

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

Similar topics

3
by: lonelyplanet999 | last post by:
Hi, I'm a newbie to perl and is now studying about perl programming, I read some perl programming tutorials online (enter 'Perl tutorial' at google.com) and also find some sample perl scripts...
2
by: Paul Porcelli | last post by:
Hi folks, I have a perl one-liner embedded in a ksh script. perl -pi.bak -e "s/val/otherval/" inputfile I'd like to check the return code to know if the substitution was successful. If I...
3
by: PzYon | last post by:
Hey 2gether! I'm trying to execute a PERL script on the web server when the user presses a button in an ASP.NET Web Application using Visual Basic. The most obvious solution for me seemed to be...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
22
by: Dan Rumney | last post by:
Hi all, I've been writing Javascript for quite a while now and have, of late, been writing quite a lot of AJAX and AJAX-related code. In the main, my dynamically generated pages are created...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.