convert pdf to searchable

I’m trying to write a script that, after importing a pdf, will automatically run OCR on it.

I’ve found two commands in the dictionary that look promising, but I can’t figure out how to use them. Please note, I am an AppleScript neophyte.

Here’s my attempt at converting the currently selected item to searchable pdf:

tell application "DEVONthink Pro"
	set theSelection to selection
	if theSelection is {} then error "Please select some contents."
	repeat with i from 1 to the count of theSelection
		set thisItem to (item i of theSelection)
		set newItem to convert image ??? record thisItem
		delete record thisItem
	end repeat
end tell

As you can see, I’m not sure what goes in place of the ???. I also can’t figure out the difference between the “convert image” command and the “OCR” command. Which one should I be using?

Anyone care to enligthen me?


Nothing goes in place of the “???”, your script should work without it. But why go through the trouble of first importing and then converting? The following script will do what you want (the timeout is important):

set myFile to alias "tiger:Users:annard:Temp:Test:Scanjob_234_20060606_174355.pdf"
tell application "DEVONthink Pro"
	local newRecord, theGroup
	-- note that you can set theGroup where the record has to go
	with timeout of 500 seconds
		set newRecord to ocr file myFile --to theGroup
	end timeout
end tell

You have to change a couple of things but it show what you’ll have to do. Good luck!