Sha256: 05670f032950b29a2355271d92f92ef557d77c7d7e1e5e4f1316c79ea6bcfb7a
Contents?: true
Size: 842 Bytes
Versions: 7
Compression:
Stored size: 842 Bytes
Contents
require "tempfile" require "poppler" require "rabbit/element" require "rabbit/parser/base" module Rabbit module Parser class PDF < Base unshift_loader(self) class << self def match?(source) extension = source.extension if extension.nil? source.read.start_with?("%PDF-1.") else /\Apdf\z/i =~ extension end end end include Element def parse @pdf = Tempfile.new("rabbit-pdf") @pdf.binmode @pdf.print(@source.read) @pdf.close doc = Poppler::Document.new("file://#{@pdf.path}") title_page, *rest = doc.to_a @canvas << PopplerTitleSlide.new(title_page, doc) rest.each do |page| @canvas << PopplerSlide.new(page) end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems