Sha256: 24c1c33cfda0d47b5f70ae6e8f712a43e8a63cac46d754219f92a85e7d2c1547

Contents?: true

Size: 706 Bytes

Versions: 4

Compression:

Stored size: 706 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)
          /\A%PDF-1\.\d\s/m =~ source.read
        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

4 entries across 4 versions & 1 rubygems

Version Path
rabbit-0.9.2 lib/rabbit/parser/pdf.rb
rabbit-0.9.1 lib/rabbit/parser/pdf.rb
rabbit-0.9.0 lib/rabbit/parser/pdf.rb
rabbit-0.6.4 lib/rabbit/parser/pdf.rb