Sha256: a10e22af0f9a7cf5ff5ff15f25507cb0a5da359a499fce866e782e005e8e52b2

Contents?: true

Size: 789 Bytes

Versions: 1

Compression:

Stored size: 789 Bytes

Contents

require "poppler"

module Mireru
  module Widget
    class PDF
      class << self
        def create(file)
          drawing_area = Gtk::DrawingArea.new

          document = Poppler::Document.new(file)
          width, height = document.first.size
          drawing_area.set_size_request(width, height * document.size)

          drawing_area.signal_connect("draw") do |widget, event|
            context = widget.window.create_cairo_context
            document.each_with_index do |page, i|
              context.save do
                context.translate(0, height * i)
                context.render_poppler_page(document[i])
              end
            end
            context.show_page
            true
          end

          drawing_area
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mireru-0.2.1 lib/mireru/widget/pdf.rb