Class: ODDB::CoMarketing::PdfParser

Inherits:
Object
  • Object
show all
Defined in:
ext/comarketing/src/pdf_parser.rb

Defined Under Namespace

Classes: CallbackHandler

Instance Method Summary (collapse)

Constructor Details

- (PdfParser) initialize(path)

A new instance of PdfParser



57
58
59
60
61
# File 'ext/comarketing/src/pdf_parser.rb', line 57

def initialize(path)
  open(path) { |fh|
    @rpdf2txt = Rpdf2txt::Parser.new(fh.read, 'UTF-8')
  }
end

Instance Method Details

- (Object) extract_pairs



62
63
64
65
66
67
68
# File 'ext/comarketing/src/pdf_parser.rb', line 62

def extract_pairs
  handler = CallbackHandler.new
  catch(:vet_products) {
    @rpdf2txt.extract_text(handler)
  }
  handler.pairs
end