Sha256: 9a64fdce5307191d33d90f7144ad9d22c3a495a3febc5c6f985a87ecef3580d4

Contents?: true

Size: 708 Bytes

Versions: 6

Compression:

Stored size: 708 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)
          source.read.start_with?("%PDF-1.")
        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

6 entries across 6 versions & 1 rubygems

Version Path
rabbit-1.0.4 lib/rabbit/parser/pdf.rb
rabbit-1.0.3 lib/rabbit/parser/pdf.rb
rabbit-1.0.2 lib/rabbit/parser/pdf.rb
rabbit-1.0.1 lib/rabbit/parser/pdf.rb
rabbit-1.0.0 lib/rabbit/parser/pdf.rb
rabbit-0.9.3 lib/rabbit/parser/pdf.rb