Class: Rabbit::ImageManipulable::PDF

Inherits:
Base
  • Object
show all
Defined in:
lib/rabbit/image/pdf.rb

Constant Summary

Constants included from ModuleLoader

ModuleLoader::LOADERS

Instance Attribute Summary

Attributes inherited from Base

#height, #original_height, #original_width, #width

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#[], #[]=, #initialize, #keep_ratio, #keep_ratio=, #resize

Methods included from ModuleLoader

extend_object, #find_loader, #loaders, #push_loader, #unshift_loader

Constructor Details

This class inherits a constructor from Rabbit::ImageManipulable::Base

Class Method Details

.match?(filename) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
# File 'lib/rabbit/image/pdf.rb', line 14

def match?(filename)
  File.open(filename) do |f|
    line = f.gets
    line and /\A%PDF-1\.\d\z/ =~ line.chomp
  end
rescue ArgumentError
  false
end

Instance Method Details

#draw(canvas, x, y, params = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rabbit/image/pdf.rb', line 24

def draw(canvas, x, y, params={})
  if @doc and canvas.poppler_available?
    default_params = {
      :width => width,
      :height => height,
    }
    canvas.draw_poppler_page(page, x, y, default_params.merge(params))
  else
    super
  end
end

#pixbufObject



36
37
38
# File 'lib/rabbit/image/pdf.rb', line 36

def pixbuf
  @pixbuf ||= to_pixbuf
end