How to translate this Applescript into rb-appscript?

108 Views Asked by At

I have the following Applescript that uses PDFpen to OCR a document.

tell application "PDFpenPro"
    open theFile as alias
    tell document 1
        ocr

        repeat while performing ocr
            delay 1
        end repeat
        delay 1
        close with saving
    end tell
end tell

The repeat block at the end waits for the document to finish before the rest of the script continues. I cannot seem to replicate this part of the logic in rb-appscript. Any help would be appreciated.

1

There are 1 best solutions below

0
On

I figured this out. Here is the resulting rb-appscript code.

    doc = @app.open MacTypes::Alias.path(file)
    doc.ocr

    while doc.performing_ocr.get
      sleep 1
    end
    doc.close(:saving => :yes)