I had this code working just fine in Acrobat 8 under Tiger. Now that I am in Leopard on an Intel machine, I get an error that Acrobat doesn’t understand the do script command.
Anyone know why this doesn’t work anymore??
tell application "Adobe Acrobat Professional"
set theJava to "var p = this.pageNum;
var n = this.getPageNumWords(p);
var str = \"\";
for(var i=0;i<n;i++) {
var wd = this.getPageNthWord(p, i, false);
if(wd != \"\") str = str + wd;}"
set theText to (do script theJava)
end tell
Model: iMac Intel 10.5.5
Browser: Firefox 3.0.2
Operating System: Mac OS X (10.5)
Indeed, awesome. And indeed, thank you for that unicode-to-data thing. I’m currently on Tiger (10.4.11) with Acrobat 8 trying to setup a system that will have to have more machines installed, and they’ll come with Leopard (or whatever is the latest by the time bosses approve purchases) and even Acrobat 9 or later; so I’m a little worried about the workarounds I go thru that will have to be re-worked around all over again.
I’m curious, tho. You state that AppleScript 2.0 is Leopard, but my Script Editor in Tiger says it’s version 2.1.2 - is the AppleScript version less important than the difference in the way the OS version handles unicode text?
When working in Tiger with Acrobat 8, I encountered some trouble with the do script command that wouldn’t handle applescript text strings until I found a slick trick here (can’t find the link now, dang it) that solved it. Essentially:
set {text:stringPath} to (quoted form of POSIX path of stringPath) as string
return stringPath
I was having problems forming a javascript string that would fail in Acrobat 8 because of unicode versus not unicode or something; mostly it had to do with things that worked in Acrobat 6 that no longer worked in Acrobat 8. Now I’m wondering if this coercion of unicode text into javascript-for-Acrobat text will no longer work in Acrobat 8 on Leopard. Does it?
I’ll try Jacques ConvertUnicodeToDataText(t) method later on to see if it also solves the problem that the one shown above does. I’d really like to find a solution that works on both Tiger and Leopard, as well as both Acrobat 8 and above. Makes planning the migration and retooling a bit less cumbersome.
Hmmmmm… Lot’s more going on than just the Acrobat versions, and it appears there’s a LOT of changes to AppleScript between the one I got and the one that’s in Leopard.
Doh! Now it makes perfect sense. I’m not a programmer by trade so the terminology might not be accurate, but essentially it’s that the version of the compiler isn’t the same as the version of the language that it’s compiling. Ah ha! Which explains…
When I run Jacques’ script on either of my iMacs (one Intel, one not) I get the error “Way too long dude!” when it pumps the ‘theJava’ text thru ‘convertUnicodeToDataText(t)’ specifically at the line
return «data TEXT" & the result & "»
because the amount of data and/or characters in the data is, well, way too long. If I reduce the amount of Unicode text to pass thru it, then it works. Both my macs are running OSX 10.4, Tiger, and so AppleScript version 1.10.7 cannot handle that much data. I found a couple other posts regarding that error and specifically what is overflowing, but at this point it’s moot for me since it appears the necessary bit is to run a run script on strings that compile Unicode text into data. Plus I won’t have to worry until/unless management decides to let me upgrade both the OS and Acrobat and see what has to be done to keep it all running.