class Pdftotext::Document

Attributes

path[R]

Public Class Methods

new(path) click to toggle source
# File lib/pdftotext/document.rb, line 5
def initialize(path)
  @path = File.expand_path(path)
end

Public Instance Methods

pages(options={}) click to toggle source
# File lib/pdftotext/document.rb, line 16
def pages(options={})
  pages = text(options).split("\f")
  pages.each_with_index.map { |t,i| Page.new text: t, number: i+1 }
end
text(options={}) click to toggle source
# File lib/pdftotext/document.rb, line 9
def text(options={})
  Tempfile.open(['pdftotext', '.txt']) do |file|
    Pdftotext.cli.run_command path, file.path, options
    file.read
  end
end