lib/grim/pdf.rb in grim-1.0.0 vs lib/grim/pdf.rb in grim-1.1.0
- old
+ new
@@ -7,14 +7,19 @@
# Raises an error if pdf not found and sets some instance
# variables if pdf is found.
#
# path - A String or Path to the pdf
+ # options - A Hash of options.
+ # :pdftotext_path - The String path of where to find the pdftotext
+ # binary to use when extracting text
+ # (default: "pdftotext").
#
- def initialize(path)
+ def initialize(path, options = {})
raise Grim::PdfNotFound unless File.exists?(path)
@path = path
+ @pdftotext_path = options[:pdftotext_path] || 'pdftotext'
end
# Shells out to ghostscript to read the pdf with the pdf_info.ps script
# as a filter, returning the number of pages in the pdf as an integer.
#
@@ -41,16 +46,16 @@
#
# Returns an instance of Grim::Page.
#
def [](index)
raise Grim::PageNotFound unless index >= 0 && index < count
- Grim::Page.new(self, index)
+ Grim::Page.new(self, index, pdftotext_path: @pdftotext_path)
end
def each
(0..(count-1)).each do |index|
- yield Grim::Page.new(self, index)
+ yield Grim::Page.new(self, index, pdftotext_path: @pdftotext_path)
end
end
end
-end
\ No newline at end of file
+end