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: Håvard Graudo <email@hidden>
- Date: Fri, 9 Jan 2009 11:15:58 +0100
Den 8. jan.. 2009 kl. 13.24 skrev Barry Wainwright:
Not sure how reliable it is, but this seems to work on all PDFs I
have tried it on:
on open theFiles
set fileData to read (item 1 of theFiles)
set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's
text item delimiters, {"/Type /Pages"}}
set dataChunk to last text item of fileData
set AppleScript's text item delimiters to {"/Count "}
set pageCount to first word of last text item of dataChunk
set AppleScript's text item delimiters to oldTIDS
return pageCount
end open
Barry
Den 8. jan.. 2009 kl. 20.30 skrev Roger Howard:
[...]
rxcountpages = re.compile(r"$\s*/Type\s*/Page[/\s]", re.MULTILINE|
re.DOTALL)
[...]
The above approach fails on some PDFs. There are more than one
instance of "/Type\s*/Page" in some PDFs and they pick the wrong one
in some PDFs, returning the wrong number of pages.
Using Python with getNumberOfPages() from CoreGraphics as Jeremy
suggested seem to handle this correctly.
Håvard
_______________________________________________
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