• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: count pages in PDF on OS 10.4
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >count pages in PDF on OS 10.4 (From: Håvard Graudo <email@hidden>)
 >Re: count pages in PDF on OS 10.4 (From: Jeremy Sellors <email@hidden>)
 >Re: count pages in PDF on OS 10.4 (From: Håvard Graudo <email@hidden>)
 >Re: count pages in PDF on OS 10.4 (From: Philip Aker <email@hidden>)
 >Re: count pages in PDF on OS 10.4 (From: Håvard Graudo <email@hidden>)

  • Prev by Date: How would I trim off 5 inches from the right side of a PDF in Acrobat using AppleScript?
  • Next by Date: Re: Converting Tiff's to PDF
  • Previous by thread: Re: count pages in PDF on OS 10.4 (solved)
  • Next by thread: Re: count pages in PDF on OS 10.4
  • Index(es):
    • Date
    • Thread