Extracting text from PDF

Kay C Lan lan.kc.macmail at gmail.com
Sat Feb 23 04:48:38 EST 2008


Stop the Presses!!!!

I'm over the moon, I can't believe I missed this before, I can't believe how
many circles I've run, but I thought I'd have another go at trying to
eliminating the step of creating an extra document, I want AppleScript to
talk directly to Rev, and I'VE FOUND IT :-)

Read the Doc's, Read the Doc's, Read the Doc's. As bad as we complain they
are, there is still so much in there if only I took in what I read;-)

Here's what the Doc's say about the 'do' command:

If you use the do as OSALanguageName form, any result returned by the script
language is placed in the result.

ANY result from AppleScript will be placed in Rev's 'the result'

I look at AppleScript's 'Event Log' window all the time to check the
'Result' of each major step. The first step of my script is to put the text
of the document into a variable. is that a result?. So, out of interest I
removed all the following steps so the only step of the script was to place
the text into an AppleScript variable.

Then in Rev I simply ' put the result into myVariable'. And there it was,
all the text. It's that easy!!! The only minor minor problem is that in
comes in AppleScript format, which means there are quotes around the
content, but a quick 'put char 2 to -2' will eliminate those.

So in Rev:

use the launch command to force a pdf to open with TextEdit

use do to run this AppleScript:

tell application "TextEdit"
    set tText to the text of document 1
end tell

put the result into myVariable --is now full of your pdf's text :-))))
put char 2 to -2 of myVariable into myVariable --remove quotes

you'll probably want to do another 'do' to run this AppleScript to close the
document

tell application "TextEdit"
    close document 1
    --or if your finished with TextEdit
    quit
    --you will be prompted to save if there are any unsaved docs
end tell

Now to go and celebrate with some really loud Stevie Ray Vaughn...The house
is a rockin' so don't bother knockin'



More information about the use-livecode mailing list