Class: Rabbit::ImageManipulable::PDF
- Includes:
- GetText
- Defined in:
- lib/rabbit/image/pdf.rb
Constant Summary
Constants included from GetText
Constants included from ModuleLoader
Instance Attribute Summary
Attributes inherited from Base
#animation, #original_height, #original_width, #properties
Class Method Summary collapse
Instance Method Summary collapse
Methods included from GetText
Methods inherited from Base
#[], #[]=, delegate, #height, #initialize, #keep_ratio=, #keep_ratio?, #relative_clip_height, #relative_clip_width, #relative_clip_x, #relative_clip_y, #resize, #width
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
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rabbit/image/pdf.rb', line 30 def match?(filename) return true if File.extname(filename) == ".pdf" File.open(filename, "rb") do |file| data = file.read(10) return false if data.nil? data.start_with?("%PDF-1.") end end |
Instance Method Details
#draw(canvas, x, y, params = {}) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/rabbit/image/pdf.rb', line 42 def draw(canvas, x, y, params={}) if @document default_params = default_draw_params(x, y) canvas.draw_poppler_page(page, x, y, default_params.merge(params)) else super end end |
#pixbuf ⇒ Object
51 52 53 |
# File 'lib/rabbit/image/pdf.rb', line 51 def pixbuf @pixbuf ||= to_pixbuf end |
#update_size ⇒ Object
55 56 57 58 |
# File 'lib/rabbit/image/pdf.rb', line 55 def update_size @document = Poppler::Document.new(uri) @width, @height = page.size end |