Extract pages and text from a PDF
masterUse Grim.reap(path) to create a Grim::Pdf instance. From there, you can access individual pages, count pages, extract text, or save pages as images.
Note: Page indexing is 0-based (e.g., pdf[0] is the first page).
pdf = Grim.reap("/path/to/pdf") # returns Grim::Pdf instance
count = pdf.count # returns number of pages
png = pdf[3].save('/path/to/image.png') # returns true if saved, false otherwise
text = pdf[3].text # returns text as a String
# Iterate through all pages
pdf.each do |page|
puts page.text
end