Sha256: 1dbe665801a95d13a6b7f01c39de1b34f8cffe3e20e7174816de4ec53c8c6aa1

Contents?: true

Size: 790 Bytes

Versions: 3

Compression:

Stored size: 790 Bytes

Contents

require 'forwardable'

module PDF
  class Inspector
    class Page < Inspector
      extend Forwardable

      attr_reader :pages

      def_delegators :@state, :set_text_font_and_size
      
      def initialize
        @pages = []
      end

      def page=(page)
        @pages << {:size => page.attributes[:MediaBox][-2..-1], :strings => []}
        @state = PDF::Reader::PageState.new(page)
      end                       

      def show_text(*params)
        params.each do |param|
          @pages.last[:strings] << @state.current_font.to_utf8(param)
        end
      end

      def show_text_with_positioning(*params)      
        # ignore kerning information
        show_text params[0].reject { |e|
          Numeric === e
        }.join
      end
      
    end   
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pdf-inspector-1.2.1 lib/pdf/inspector/page.rb
pdf-inspector-1.2.0 lib/pdf/inspector/page.rb
pdf-inspector-1.1.0 lib/pdf/inspector/page.rb