Class: Util::ExtractPdfText

Inherits:
Object show all
Defined in:
lib/utilities/extract_pdf_text.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pdf) ⇒ ExtractPdfText

Returns a new instance of ExtractPdfText.



5
6
7
8
9
# File 'lib/utilities/extract_pdf_text.rb', line 5

def initialize(pdf)
  @pdf = pdf
  @extracted_text = ''
  read_text
end

Instance Attribute Details

#extracted_textObject (readonly)

Returns the value of attribute extracted_text.



11
12
13
# File 'lib/utilities/extract_pdf_text.rb', line 11

def extracted_text
  @extracted_text
end

Instance Method Details

#read_textObject



13
14
15
16
17
18
# File 'lib/utilities/extract_pdf_text.rb', line 13

def read_text
  reader = PDF::Reader.new(@pdf.path)
  reader.pages.each do |page|
    @extracted_text += page.text
  end
end