Re: count pages in PDF on OS 10.4
Re: count pages in PDF on OS 10.4
- Subject: Re: count pages in PDF on OS 10.4
- From: "Roger Howard" <email@hidden>
- Date: Thu, 8 Jan 2009 11:30:35 -0800 (PST)
On Thu, January 8, 2009 12:38 am, Håvard Graudo wrote:
>>> On 2009-01-07, at 23:49:31, Håvard Graudo wrote:
>>> Now, does anyone have a fast and easy way to get number of pages in
>>> PDF-files that will also work on files on a server?
>>
>
>
>
> Thanks Wayne, Philip and Emmanuel
>
> I was hoping for a more generic solution if possible.
>
> Maybe I should dive into Python?
Here's a pure python way I found a while back which you could easily adapt
to any language with regex support (or just call from AppleScript)...
-----
import re
rxcountpages = re.compile(r"$\s*/Type\s*/Page[/\s]", re.MULTILINE|re.DOTALL)
def countPages(filename):
data = file(filename,"rb").read()
return len(rxcountpages.findall(data))
if __name__=="__main__":
print "Number of pages in PDF File:", countPages("test.pdf")
-----
Courtesy of http://code.activestate.com/recipes/496837/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden