Class: PaperlessOCR::PDFpenPro

Inherits:
Object
  • Object
show all
Defined in:
lib/paperless/ocr_engines/pdfpenpro.rb

Instance Method Summary collapse

Constructor Details

#initializePDFpenPro

Returns a new instance of PDFpenPro.



9
10
11
12
13
# File 'lib/paperless/ocr_engines/pdfpenpro.rb', line 9

def initialize
    @engine = PaperlessOCR::PDFPENPRO
    @app = app(@engine)
    @app.activate
end

Instance Method Details

#ocr(options) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/paperless/ocr_engines/pdfpenpro.rb', line 15

def ocr(options)
  begin
    doc = @app.open MacTypes::Alias.path(options[:file])
    doc.ocr

    app("System Events").processes[@engine].visible.set(false)

    while doc.performing_ocr.get
      sleep 1
    end
    doc.close(:saving => :yes)
    sleep 3
  rescue 
    puts "WARNING: There was an error OCRing the document with #{@engine}: #{$!}"
  end
end