Class: Rabbit::Parser::PDF
Constant Summary
ModuleLoader::LOADERS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize
extend_object, #find_loader, #loaders, #push_loader, #unshift_loader
Class Method Details
29
30
31
|
# File 'lib/rabbit/parser/pdf.rb', line 29
def format_name
"PDF"
end
|
.match?(source) ⇒ Boolean
33
34
35
36
37
38
39
40
|
# File 'lib/rabbit/parser/pdf.rb', line 33
def match?(source)
extension = source.extension
if extension.nil?
source.read.start_with?("%PDF-1.")
else
/\Apdf\z/i =~ extension
end
end
|
Instance Method Details
#parse ⇒ Object
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/rabbit/parser/pdf.rb', line 44
def parse
doc = Poppler::Document.new(:data => @source.read)
doc.each_with_index do |page, i|
if i.zero?
@canvas << PopplerTitleSlide.new(page, doc)
else
@canvas << PopplerSlide.new(page)
end
end
end
|