Page 1 of 1

Count of Pages in PDF

Posted: Thu Sep 28, 2017 7:12 pm
by foxpalace
Hi,
I think I am stupid, but how do I count the Pages of an PDF?
- mdls won't work - a) via spotlight via launchctl deactivatet b) the flow is too fast
- I tried exiftool, but

Code: Select all

	var getPages = ("/usr/bin/perl /usr/local/Cellar/exiftool/10.55/bin/exiftool -\"*Count\" " + OrigFile);
	s.log(1, "getPages: " + getPages);
	var doIt = Process.execute(getPages);
	s.log(1, "doIt: " + Process.stdout);
	var myOut = Process.stdout;
	s.log(1, "myOut: " + myOut);
doIt is empty - ok, I have to use there Switch 12 update 3 - mybe a bug there? If i paste getPages in Terminal I get my output, but in Switch is empty.
Is there a simple way to get the pagecount of my pdf?

Re: Count of Pages in PDF

Posted: Thu Sep 28, 2017 7:47 pm
by r.zegwaard
Hi foxpalace,

You can do it like this using the FileStatistics

Code: Select all

fs = new FileStatistics(job.getPath());
n = fs.getNumber('NumberOfPages');
s.log(-1,n);

Re: Count of Pages in PDF

Posted: Fri Sep 29, 2017 7:23 am
by foxpalace
Hi Zegwaard,

great - works like a charm :)

Re: Count of Pages in PDF

Posted: Fri Oct 06, 2017 10:30 am
by Arthur
May I kindly ask a small bit, as a newbie ?
How do I actually use / trigger the Filestatistics ? Am I right in thinking - this requires Scripting Module solely and cannot be used without it ?
I would be very much interested in this functionality, but have no scripting module ...

Re: Count of Pages in PDF

Posted: Fri Oct 06, 2017 11:36 am
by jan_suhr
You can get the number of pages as a variable in the Stats set.