Class: Pdftotext::Document
- Inherits:
-
Object
- Object
- Pdftotext::Document
- Defined in:
- lib/pdftotext/document.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ Document
constructor
A new instance of Document.
- #pages(options = {}) ⇒ Object
- #text(options = {}) ⇒ Object
Constructor Details
#initialize(path) ⇒ Document
5 6 7 |
# File 'lib/pdftotext/document.rb', line 5 def initialize(path) @path = File.(path) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/pdftotext/document.rb', line 3 def path @path end |
Instance Method Details
#pages(options = {}) ⇒ Object
16 17 18 19 |
# File 'lib/pdftotext/document.rb', line 16 def pages(={}) pages = text().split("\f") pages.each_with_index.map { |t,i| Page.new text: t, number: i+1 } end |
#text(options = {}) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/pdftotext/document.rb', line 9 def text(={}) Pdftotext.cli.run_command path, tempfile.path, text = tempfile.read tempfile.close! text end |