RE:Parsing PDF; looking to count number of markup annotations per re viewer (user) in Mac OS 9.2.2.
RE:Parsing PDF; looking to count number of markup annotations per re viewer (user) in Mac OS 9.2.2.
- Subject: RE:Parsing PDF; looking to count number of markup annotations per re viewer (user) in Mac OS 9.2.2.
- From: email@hidden
- Date: Thu, 18 Dec 2003 13:31:05 -0500
- Priority: normal
Hi Christopher,
I really like your method below. That's pretty slick! :-)
I haven't had a whole lot of luck scripting Acrobat, but
maybe this example might be useful. Basically, you can grab
the 'name' of an annotation in order to get the person's
name (I think this is what you're after). I've written a
loop below that runs through each page of document 1 and
grabs the name out of each annotation. The reason I added
'by 2' after the second loop is for some reason it gives me
the same person's name twice each time (as if there's 2
annotations of each one). I'm not real familiar with
annotations, but this seemed to work decently with the file
I have. When you run this code it will give you a list of
names in Script Editor's Result Window. The next step of
course is sorting this list of names in order to get the
count of each person. Hope this helps.
(tested in OS 10.2.6 and I believe this should work in OS 9)
-----------------------
tell application "Acrobat 5.0"
tell document 1
set annotAuthor to {}
repeat with p from 1 to (count pages)
repeat with a from 1 to (count page p's annotations) by 2
set annotAuthor's end to (page p's annotation a's name)
end repeat
end repeat
end tell
end tell
annotAuthor
-----------------------
Jay
=====================================
Christopher wrote:
Subject: Parsing PDF; looking to count number of markup
annotations per re viewer (user) in Mac OS 9.2.2.
To: "'email@hidden'"
<email@hidden>
From: "Fox, Christopher B" <email@hidden>
Date: Thu, 18 Dec 2003 09:59:41 -0500
I'd like to come up with a way in Mac OS 9 to count the
number of
annotations per reviewer in a PDF file. AppleScript seems
like the only
solution. Unfortunately, Adobe Acrobat 5 has a fairly
limited AppleScript
dictionary, which also seems to be largely broken. So, I've
decided to
tackle the PDF file itself, rather then expect to get any
help from Acrobat.
I've taken a gander at the PDF 1.5 spec from Adobe's
website, and I
came up with the following string of Unix shell commands
that seem to work
great in Mac OS X 10.3.2:
strings test.pdf | awk '/\/Type \/Annot/, /endobj/' | grep
'/T ' | sort |
uniq -c
Essentially what this does is:
1) Eliminate binary data, and put the resulting strings on
separate lines.
2) Filter out lines not between "/Type /Annot" and "endobj"
pairs. This
eliminates anything not an Annotation object.
3) Filter once again, selecting only lines that begin with
'/T ' which is
the markup annotation key that indicates the user or
reviewer who made the
annotation.
4) Sort the remaining lines.
5) Count the number of times each unique line occurs, and
print the results.
Unfortunately, our user population is still on Mac OS
9.2.2, so Unix
solutions aren't an option. I know AppleScript has direct
file access
capability (using open for access, read, write, close
access, etc.), but I
can't seem to get the equivalent of "strings" or the awk
pattern recognition
out of AppleScript.
Any thoughts would be most appreciated.
Thanks!
Christopher Fox
>
CapitalOne
Senior Technician, Enterprise Macintosh Support Services
MSG-IT
Tel: Internal: 425-1553; External: 804-967-1553
Mobile: 804-301-4117
email: email@hidden
**************************************************************************
The information transmitted herewith is sensitive
information intended only
for use by the individual or entity to which it is
addressed. If the reader
of this message is not the intended recipient, you are
hereby notified that
any review, retransmission, dissemination, distribution,
copying or other
use of, or taking of any action in reliance upon this
information is
strictly prohibited. If you have received this communication
in error,
please contact the sender and delete the material from your
computer.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.