Sha256: 1a22738e8ca788de255ab47ce41b6917f2b02c5fe60101deea1b6fdfe94311ac

Contents?: true

Size: 771 Bytes

Versions: 5

Compression:

Stored size: 771 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 format_name
          "PDF"
        end

        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
        doc = Poppler::Document.new(@source.read)

        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

5 entries across 5 versions & 1 rubygems

Version Path
rabbit-2.2.1 lib/rabbit/parser/pdf.rb
rabbit-2.2.0 lib/rabbit/parser/pdf.rb
rabbit-2.1.9 lib/rabbit/parser/pdf.rb
rabbit-2.1.8 lib/rabbit/parser/pdf.rb
rabbit-2.1.7 lib/rabbit/parser/pdf.rb